[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7e13a94b-2e92-850f-33f7-0f42cfcd9009@redhat.com>
Date: Mon, 13 Apr 2020 17:52:24 -0400
From: Waiman Long <longman@...hat.com>
To: Joe Perches <joe@...ches.com>,
Andrew Morton <akpm@...ux-foundation.org>,
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>,
Matthew Wilcox <willy@...radead.org>,
David Rientjes <rientjes@...gle.com>
Cc: linux-mm@...ck.org, keyrings@...r.kernel.org,
linux-kernel@...r.kernel.org, x86@...nel.org,
linux-crypto@...r.kernel.org, linux-s390@...r.kernel.org,
linux-pm@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-amlogic@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linuxppc-dev@...ts.ozlabs.org,
virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
intel-wired-lan@...ts.osuosl.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-btrfs@...r.kernel.org,
linux-cifs@...r.kernel.org, samba-technical@...ts.samba.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,
cocci@...teme.lip6.fr, linux-security-module@...r.kernel.org,
linux-integrity@...r.kernel.org
Subject: Re: [PATCH 2/2] crypto: Remove unnecessary memzero_explicit()
On 4/13/20 5:31 PM, Joe Perches wrote:
> On Mon, 2020-04-13 at 17:15 -0400, Waiman Long wrote:
>> Since kfree_sensitive() will do an implicit memzero_explicit(), there
>> is no need to call memzero_explicit() before it. Eliminate those
>> memzero_explicit() and simplify the call sites.
> 2 bits of trivia:
>
>> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> []
>> @@ -391,10 +388,7 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
>> dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen);
>> return -EINVAL;
>> }
>> - if (op->key) {
>> - memzero_explicit(op->key, op->keylen);
>> - kfree(op->key);
>> - }
>> + kfree_sensitive(op->key);
>> op->keylen = keylen;
>> op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
>> if (!op->key)
> It might be a defect to set op->keylen before the kmemdup succeeds.
It could be. I can move it down after the op->key check.
>> @@ -416,10 +410,7 @@ int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
>> if (err)
>> return err;
>>
>> - if (op->key) {
>> - memzero_explicit(op->key, op->keylen);
>> - kfree(op->key);
>> - }
>> + free_sensitive(op->key, op->keylen);
> Why not kfree_sensitive(op->key) ?
Oh, it is a bug. I will send out v2 to fix that.
Thanks for spotting it.
Cheers,
Longman
>
>
Powered by blists - more mailing lists