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.
Showing the changes to include/linux (1 of 4 files). Show all
Unified · Split
| @@ -776,6 +776,7 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) · 775 unmodified lines | |||
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | extern void kvfree(const void *addr); | 778 | extern void kvfree(const void *addr); |
| 779 | extern void kvfree_sensitive(const void *addr, size_t len); | ||
| 779 | 780 | ||
| 780 | /* | 781 | /* |
| 781 | * Mapcount of compound page as a whole, does not include mapped sub-pages. | 782 | * Mapcount of compound page as a whole, does not include mapped sub-pages. |