1

My Linux kernal version change from 4.18 to 5.14 recently. When I compile one of my ko, I got some errors in Makefile maybe. It told me that ERROR: modpost "memset_s" [xxx/xxx/xxx.ko] undefined!. If I can add EXPORT_SYMBOL() in the source file, how can I solve this problem

If I can't add EXPORT_SYMBOL() in the source code, how can I solve this problem

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
Dog Fish
  • 13
  • 3

2 Answers2

2

For most practical purposes, memset_s() and the other _s "safe" functions are only implemented by Microsoft on Windows. Therefore, memset_s() almost certainly won't work in the Linux kernel. (Having said that, it is intriguing that it used to work.)

There is considerable resistance to implementing the functions outside of Microsoft. However, C23 adds the function memset_explicit(), which is supposed to guarantee that the memory is set — the compiler is not supposed to optimize it out. That is valuable for zapping passwords in memory, for example. This property was also required by the specification of memset_s().

See also Do you use the TR-24731 'safe' functions? for considerable information about the Annex K functions.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
0

memset_s and friends are available through the safec library. Note that there are special instructions halfway down this page on using this with Linux kernel modules.

HardcoreHenry
  • 5,909
  • 2
  • 19
  • 44