History

mm: add kvfree_sensitive() for freeing sensitive data objects

For kvmalloc'ed data object that contains sensitive information like cryptographic keys, we need to make sure that the buffer is always cleared before freeing it. Using memset() alone for buffer clearing may not provide certainty as the compiler may compile it away. To be sure, the special memzero_explicit() has to be used. This patch introduces a new kvfree_sensitive() for freeing those sensitive data objects allocated by kvmalloc(). The relevant places where kvfree_sensitive() can be used are modified to use it.

Waiman Long committed 6 years ago

Commit d4eaa281 parent 090e77e4 files · +24 −22Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/mm.h+1−0
@@ -776,6 +776,7 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) · 775 unmodified lines
776776 }
777777
778778 extern void kvfree(const void *addr);
779+extern void kvfree_sensitive(const void *addr, size_t len);
779780
780781 /*
781782 * Mapcount of compound page as a whole, does not include mapped sub-pages.