From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Waiman Long <longman@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Howells <dhowells@redhat.com>,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Joe Perches <joe@perches.com>,
Matthew Wilcox <willy@infradead.org>,
David Rientjes <rientjes@google.com>
Cc: samba-technical@lists.samba.org,
virtualization@lists.linux-foundation.org, linux-mm@kvack.org,
linux-sctp@vger.kernel.org, target-devel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
devel@driverdev.osuosl.org, linux-s390@vger.kernel.org,
linux-scsi@vger.kernel.org, x86@kernel.org,
kasan-dev@googlegroups.com, cocci@systeme.lip6.fr,
linux-wpan@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
linux-crypto@vger.kernel.org, linux-pm@vger.kernel.org,
ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-fscrypt@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org,
netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
linux-security-module@vger.kernel.org, keyrings@vger.kernel.org,
tipc-discussion@lists.sourceforge.net, wireguard@lists.zx2c4.com,
linux-ppp@vger.kernel.org, linux-integrity@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive()
Date: Tue, 14 Apr 2020 02:32:03 -0600 [thread overview]
Message-ID: <4babf834-c531-50ba-53f6-e88410b15ce3@zx2c4.com> (raw)
In-Reply-To: <20200413211550.8307-2-longman@redhat.com>
On 4/13/20 3:15 PM, Waiman Long 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.
Seems reasonable to me. One bikeshed, that you can safely discard and
ignore as a mere bikeshed: kfree_memzero or kfree_scrub or
kfree_{someverb} seems like a better function name, as it describes what
the function does, rather than "_sensitive" that suggests something
about the data maybe but who knows what that entails. If you disagree,
not a big deal either way.
> In addition, memzero_explicit() is used to clear the
> memory to make sure that it won't get optimized away by the compiler.
This had occurred to me momentarily a number of years ago, but I was
under the impression that the kernel presumes extern function calls to
always imply a compiler barrier, making it difficult for the compiler to
reason about what happens in/after kfree, in order to be able to
optimize out the preceding memset. With LTO, that rule obviously
changes. I guess new code should be written with cross-object
optimizations in mind now a days? [Meanwhile, it would be sort of
interesting to teach gcc about kfree to enable additional scary
optimizations...]
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2020-04-14 8:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 21:15 [PATCH 0/2] mm, treewide: Rename kzfree() to kfree_sensitive() Waiman Long
2020-04-13 21:15 ` [PATCH 1/2] " Waiman Long
2020-04-14 0:29 ` David Rientjes
2020-04-14 8:32 ` Jason A. Donenfeld [this message]
2020-04-14 9:01 ` Michal Hocko
2020-04-14 12:48 ` David Sterba
2020-04-14 18:26 ` Waiman Long
2020-04-15 5:01 ` Johannes Weiner
2020-06-15 18:07 ` Dan Carpenter
2020-06-15 18:39 ` Waiman Long
2020-04-13 21:15 ` [PATCH 2/2] crypto: Remove unnecessary memzero_explicit() Waiman Long
2020-04-13 21:31 ` Joe Perches
2020-04-13 21:52 ` Waiman Long
2020-04-13 22:28 ` [PATCH v2 " Waiman Long
2020-04-14 6:08 ` Christophe Leroy
2020-04-14 16:24 ` Waiman Long
2020-04-14 19:16 ` Michal Suchánek
2020-04-14 19:37 ` Waiman Long
2020-04-14 19:44 ` Joe Perches
2020-04-14 13:06 ` [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive() David Howells
2020-04-14 20:02 ` [PATCH v3 2/3] crypto: Remove unnecessary memzero_explicit() Waiman Long
2020-04-16 9:06 ` Corentin Labbe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4babf834-c531-50ba-53f6-e88410b15ce3@zx2c4.com \
--to=jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=cocci@systeme.lip6.fr \
--cc=devel@driverdev.osuosl.org \
--cc=dhowells@redhat.com \
--cc=ecryptfs@vger.kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jmorris@namei.org \
--cc=joe@perches.com \
--cc=kasan-dev@googlegroups.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=longman@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rientjes@google.com \
--cc=samba-technical@lists.samba.org \
--cc=serge@hallyn.com \
--cc=target-devel@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=torvalds@linux-foundation.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=willy@infradead.org \
--cc=wireguard@lists.zx2c4.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).