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 scripts (4 of 114 files). Show all

Unified · Split

4 files
  1. scripts/coccinelle/free/devm_free.cocci +2 −2
  2. scripts/coccinelle/free/ifnullfree.cocci +2 −2
  3. scripts/coccinelle/free/kfree.cocci +3 −3
  4. scripts/coccinelle/free/kfreeaddr.cocci +1 −1
scripts/coccinelle/free/devm_free.cocci+2−2
@@ -89,7 +89,7 @@ position p; · 88 unmodified lines
8989 (
9090 kfree@p(x)
9191 |
92− kzfree@p(x)
92+ kfree_sensitive@p(x)
9393 |
9494 krealloc@p(x, ...)
9595 |
@@ -112,7 +112,7 @@ position p != safe.p; · 16 unmodified lines
112112 (
113113 * kfree@p(x)
114114 |
115−* kzfree@p(x)
115+* kfree_sensitive@p(x)
116116 |
117117 * krealloc@p(x, ...)
118118 |
scripts/coccinelle/free/ifnullfree.cocci+2−2
@@ -21,7 +21,7 @@ expression E; · 20 unmodified lines
2121 (
2222 kfree(E);
2323 |
24− kzfree(E);
24+ kfree_sensitive(E);
2525 |
2626 debugfs_remove(E);
2727 |
@@ -42,7 +42,7 @@ position p; · 14 unmodified lines
4242 @@
4343
4444 * if (E != NULL)
45−* \(kfree@p\|kzfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|
45+* \(kfree@p\|kfree_sensitive@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|
4646 * usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\|
4747 * dma_pool_destroy@p\)(E);
4848
scripts/coccinelle/free/kfree.cocci+3−3
@@ -24,7 +24,7 @@ position p1; · 23 unmodified lines
2424 (
2525 * kfree@p1(E)
2626 |
27−* kzfree@p1(E)
27+* kfree_sensitive@p1(E)
2828 )
2929
3030 @print expression@
@@ -68,7 +68,7 @@ while (1) { ... · 37 unmodified lines
6868 (
6969 * kfree@ok(E)
7070 |
71−* kzfree@ok(E)
71+* kfree_sensitive@ok(E)
7272 )
7373 ... when != break;
7474 when != goto l;
@@ -86,7 +86,7 @@ position free.p1!=loop.ok,p2!={print.p,sz.p}; · 11 unmodified lines
8686 (
8787 * kfree@p1(E,...)
8888 |
89−* kzfree@p1(E,...)
89+* kfree_sensitive@p1(E,...)
9090 )
9191 ...
9292 (
scripts/coccinelle/free/kfreeaddr.cocci+1−1
@@ -20,7 +20,7 @@ position p; · 19 unmodified lines
2020 (
2121 * kfree@p(&e->f)
2222 |
23−* kzfree@p(&e->f)
23+* kfree_sensitive@p(&e->f)
2424 )
2525
2626 @script:python depends on org@

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