[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200616110944.c13f221e5c3f54e775190afe@linux-foundation.org>
Date: Tue, 16 Jun 2020 11:09:44 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Waiman Long <longman@...hat.com>
Cc: David Howells <dhowells@...hat.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Joe Perches <joe@...ches.com>,
Matthew Wilcox <willy@...radead.org>,
David Rientjes <rientjes@...gle.com>,
Michal Hocko <mhocko@...e.com>,
Johannes Weiner <hannes@...xchg.org>,
Dan Carpenter <dan.carpenter@...cle.com>,
"Jason A . Donenfeld" <Jason@...c4.com>, linux-mm@...ck.org,
keyrings@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-crypto@...r.kernel.org, linux-pm@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-amlogic@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linuxppc-dev@...ts.ozlabs.org,
virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
linux-ppp@...r.kernel.org, wireguard@...ts.zx2c4.com,
linux-wireless@...r.kernel.org, devel@...verdev.osuosl.org,
linux-scsi@...r.kernel.org, target-devel@...r.kernel.org,
linux-cifs@...r.kernel.org, linux-fscrypt@...r.kernel.org,
ecryptfs@...r.kernel.org, kasan-dev@...glegroups.com,
linux-bluetooth@...r.kernel.org, linux-wpan@...r.kernel.org,
linux-sctp@...r.kernel.org, linux-nfs@...r.kernel.org,
tipc-discussion@...ts.sourceforge.net,
linux-security-module@...r.kernel.org,
linux-integrity@...r.kernel.org
Subject: Re: [PATCH v5 2/2] mm, treewide: Rename kzfree() to
kfree_sensitive()
On Tue, 16 Jun 2020 11:43:11 -0400 Waiman Long <longman@...hat.com> wrote:
> 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/\bkzfree\b/kfree_sensitive/'
>
> followed by some editing of the kfree_sensitive() kerneldoc and adding
> a kzfree backward compatibility macro in slab.h.
>
> ...
>
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -186,10 +186,12 @@ void memcg_deactivate_kmem_caches(struct mem_cgroup *, struct mem_cgroup *);
> */
> void * __must_check krealloc(const void *, size_t, gfp_t);
> void kfree(const void *);
> -void kzfree(const void *);
> +void kfree_sensitive(const void *);
> size_t __ksize(const void *);
> size_t ksize(const void *);
>
> +#define kzfree(x) kfree_sensitive(x) /* For backward compatibility */
> +
What was the thinking here? Is this really necessary?
I suppose we could keep this around for a while to ease migration. But
not for too long, please.
Powered by blists - more mailing lists