mm, treewide: rename kzfree() to kfree_sensitive()
authorWaiman Long <longman@redhat.com>
Fri, 7 Aug 2020 06:18:13 +0000 (23:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 7 Aug 2020 18:33:22 +0000 (11:33 -0700)
commit453431a54934d917153c65211b2dabf45562ca88
treee9672e7fb28f59331ff00fe6197360d703cbd9c3
parent57c720d4144a9c2b88105c3e8f7b0e97e4b5cc93
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]

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Joe Perches <joe@perches.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
114 files changed:
arch/s390/crypto/prng.c
arch/x86/power/hibernate.c
crypto/adiantum.c
crypto/ahash.c
crypto/api.c
crypto/asymmetric_keys/verify_pefile.c
crypto/deflate.c
crypto/drbg.c
crypto/ecc.c
crypto/ecdh.c
crypto/gcm.c
crypto/gf128mul.c
crypto/jitterentropy-kcapi.c
crypto/rng.c
crypto/rsa-pkcs1pad.c
crypto/seqiv.c
crypto/shash.c
crypto/skcipher.c
crypto/testmgr.c
crypto/zstd.c
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
drivers/crypto/amlogic/amlogic-gxl-cipher.c
drivers/crypto/atmel-ecc.c
drivers/crypto/caam/caampkc.c
drivers/crypto/cavium/cpt/cptvf_main.c
drivers/crypto/cavium/cpt/cptvf_reqmanager.c
drivers/crypto/cavium/nitrox/nitrox_lib.c
drivers/crypto/cavium/zip/zip_crypto.c
drivers/crypto/ccp/ccp-crypto-rsa.c
drivers/crypto/ccree/cc_aead.c
drivers/crypto/ccree/cc_buffer_mgr.c
drivers/crypto/ccree/cc_cipher.c
drivers/crypto/ccree/cc_hash.c
drivers/crypto/ccree/cc_request_mgr.c
drivers/crypto/marvell/cesa/hash.c
drivers/crypto/marvell/octeontx/otx_cptvf_main.c
drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.h
drivers/crypto/nx/nx.c
drivers/crypto/virtio/virtio_crypto_algs.c
drivers/crypto/virtio/virtio_crypto_core.c
drivers/md/dm-crypt.c
drivers/md/dm-integrity.c
drivers/misc/ibmvmc.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
drivers/net/ppp/ppp_mppe.c
drivers/net/wireguard/noise.c
drivers/net/wireguard/peer.c
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
drivers/net/wireless/intersil/orinoco/wext.c
drivers/s390/crypto/ap_bus.h
drivers/staging/ks7010/ks_hostif.c
drivers/staging/rtl8723bs/core/rtw_security.c
drivers/staging/wlan-ng/p80211netdev.c
drivers/target/iscsi/iscsi_target_auth.c
fs/cifs/cifsencrypt.c
fs/cifs/connect.c
fs/cifs/dfs_cache.c
fs/cifs/misc.c
fs/crypto/inline_crypt.c
fs/crypto/keyring.c
fs/crypto/keysetup_v1.c
fs/ecryptfs/keystore.c
fs/ecryptfs/messaging.c
include/crypto/aead.h
include/crypto/akcipher.h
include/crypto/gf128mul.h
include/crypto/hash.h
include/crypto/internal/acompress.h
include/crypto/kpp.h
include/crypto/skcipher.h
include/linux/slab.h
lib/mpi/mpiutil.c
lib/test_kasan.c
mm/slab_common.c
net/atm/mpoa_caches.c
net/bluetooth/ecdh_helper.c
net/bluetooth/smp.c
net/core/sock.c
net/ipv4/tcp_fastopen.c
net/mac80211/aead_api.c
net/mac80211/aes_gmac.c
net/mac80211/key.c
net/mac802154/llsec.c
net/sctp/auth.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_keys.c
net/sunrpc/auth_gss/gss_krb5_mech.c
net/tipc/crypto.c
net/wireless/core.c
net/wireless/ibss.c
net/wireless/lib80211_crypt_tkip.c
net/wireless/lib80211_crypt_wep.c
net/wireless/nl80211.c
net/wireless/sme.c
net/wireless/util.c
net/wireless/wext-sme.c
scripts/coccinelle/free/devm_free.cocci
scripts/coccinelle/free/ifnullfree.cocci
scripts/coccinelle/free/kfree.cocci
scripts/coccinelle/free/kfreeaddr.cocci
security/apparmor/domain.c
security/apparmor/include/file.h
security/apparmor/policy.c
security/apparmor/policy_ns.c
security/apparmor/policy_unpack.c
security/keys/big_key.c
security/keys/dh.c
security/keys/encrypted-keys/encrypted.c
security/keys/trusted-keys/trusted_tpm1.c
security/keys/user_defined.c