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.