History

mm, treewide: rename kzfree() to kfree_sensitive()

As said by Linus: A symmetric naming is only helpful if it implies symmetries in use. Otherwise it's actively misleading. In "kzalloc()", the z is meaningful and an important part of what the caller wants. In "kzfree()", the z is actively detrimental, because maybe in the future we really _might_ want to use that "memfill(0xdeadbeef)" or something. The "zero" part of the interface isn't even _relevant_. The main reason that kzfree() exists is to clear sensitive information that should not be leaked to other future users of the same memory objects. Rename kzfree() to kfree_sensitive() to follow the example of the recently added kvfree_sensitive() and make the intention of the API more explicit. In addition, memzero_explicit() is used to clear the memory to make sure that it won't get optimized away by the compiler. The renaming is done by using the command sequence: git grep -w --name-only kzfree |\ xargs sed -i 's/kzfree/kfree_sensitive/' followed by some editing of the kfree_sensitive() kerneldoc and adding a kzfree backward compatibility macro in slab.h. [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h] [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]

Waiman Long committed 6 years ago

Commit 453431a1 parent 57c720d114 files · +323 −320Browse files

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

Unified · Split

include/linux/slab.h+3−1
@@ -186,10 +186,12 @@ void memcg_deactivate_kmem_caches(struct mem_cgroup *, struct mem_cgroup *); · 185 unmodified lines
186 */186 */
187void * __must_check krealloc(const void *, size_t, gfp_t);187void * __must_check krealloc(const void *, size_t, gfp_t);
188void kfree(const void *);188void kfree(const void *);
189void kzfree(const void *);189void kfree_sensitive(const void *);
190size_t __ksize(const void *);190size_t __ksize(const void *);
191size_t ksize(const void *);191size_t ksize(const void *);
192 192
193#define kzfree(x) kfree_sensitive(x) /* For backward compatibility */
194
193#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR195#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR
194void __check_heap_object(const void *ptr, unsigned long n, struct page *page,196void __check_heap_object(const void *ptr, unsigned long n, struct page *page,
195 bool to_user);197 bool to_user);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t