Module to sanitize freed memory ?

Chris Laberti chrislaberti at gmail.com
Fri May 13 08:05:40 EDT 2011


>> Hi,
>>
>> Is there a kernel module that sanitizes (overwrites) freed memory ? Or
>> maybe does sysctl offer something like this ?
>>
>> Regards,
>> Chris


>   you can always use the kzfree() routine, that zeroes freed memory
> automatically.
>
> rday



> What's wrong with the kernel option that does this for you
> (CONFIG_DEBUG_SLAB)?  No need to write a separate kernel module at all.
>
> greg k-h



Hi,

Thank you for both answers. I have enabled CONFIG_DEBUG_SLAB and
modified the memset() in kzfree() to -1 instead of 0 but memory is
zeroed rather than filled with -1. I have looked over the code but
cannot find what is zeroing the memory.

I want to use -1 so that debugging C code is easier because if the
memory is filled with zeroes (nul chars), then buffer overflows will
be hidden, making it difficult to debug.

Does anybody know what code to modify in order to fill with -1 instead of zero ?

Regards,
Chris



More information about the Kernelnewbies mailing list