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
89(89(
90 kfree@p(x)90 kfree@p(x)
91|91|
92 kzfree@p(x)92 kfree_sensitive@p(x)
93|93|
94 krealloc@p(x, ...)94 krealloc@p(x, ...)
95|95|
@@ -112,7 +112,7 @@ position p != safe.p; · 16 unmodified lines
112(112(
113* kfree@p(x)113* kfree@p(x)
114|114|
115* kzfree@p(x)115* kfree_sensitive@p(x)
116|116|
117* krealloc@p(x, ...)117* krealloc@p(x, ...)
118|118|
scripts/coccinelle/free/ifnullfree.cocci+2−2
@@ -21,7 +21,7 @@ expression E; · 20 unmodified lines
21(21(
22 kfree(E);22 kfree(E);
23|23|
24 kzfree(E);24 kfree_sensitive(E);
25|25|
26 debugfs_remove(E);26 debugfs_remove(E);
27|27|
@@ -42,7 +42,7 @@ position p; · 14 unmodified lines
42@@42@@
43 43
44* if (E != NULL)44* 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\|
46* usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\|46* usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\|
47* dma_pool_destroy@p\)(E);47* dma_pool_destroy@p\)(E);
48 48
scripts/coccinelle/free/kfree.cocci+3−3
@@ -24,7 +24,7 @@ position p1; · 23 unmodified lines
24(24(
25* kfree@p1(E)25* kfree@p1(E)
26|26|
27* kzfree@p1(E)27* kfree_sensitive@p1(E)
28)28)
29 29
30@print expression@30@print expression@
@@ -68,7 +68,7 @@ while (1) { ... · 37 unmodified lines
68(68(
69* kfree@ok(E)69* kfree@ok(E)
70|70|
71* kzfree@ok(E)71* kfree_sensitive@ok(E)
72)72)
73 ... when != break;73 ... when != break;
74 when != goto l;74 when != goto l;
@@ -86,7 +86,7 @@ position free.p1!=loop.ok,p2!={print.p,sz.p}; · 11 unmodified lines
86(86(
87* kfree@p1(E,...)87* kfree@p1(E,...)
88|88|
89* kzfree@p1(E,...)89* kfree_sensitive@p1(E,...)
90)90)
91...91...
92(92(
scripts/coccinelle/free/kfreeaddr.cocci+1−1
@@ -20,7 +20,7 @@ position p; · 19 unmodified lines
20(20(
21* kfree@p(&e->f)21* kfree@p(&e->f)
22|22|
23* kzfree@p(&e->f)23* kfree_sensitive@p(&e->f)
24)24)
25 25
26@script:python depends on org@26@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