2024-05-07 21:14:22

by Jules Irenge

[permalink] [raw]
Subject: [PATCH v3] s390/pkey: use kfree_sensitive() to fix Coccinelle warnings

Replace memzero_explicit() and kfree() with kfree_sentive() to fix
warnings reported by Coccinelle

WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1506)
WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1643)
WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1770)

Signed-off-by: Jules Irenge <[email protected]>
---
Changes in v3:
- use kfree_sensitive() instead of kvfree_sensitive as a correction

drivers/s390/crypto/pkey_api.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
index dccf664a3d95..933894065623 100644
--- a/drivers/s390/crypto/pkey_api.c
+++ b/drivers/s390/crypto/pkey_api.c
@@ -1503,8 +1503,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
rc = pkey_keyblob2pkey(kkey, ktp.keylen, ktp.protkey.protkey,
&ktp.protkey.len, &ktp.protkey.type);
pr_debug("%s pkey_keyblob2pkey()=%d\n", __func__, rc);
- memzero_explicit(kkey, ktp.keylen);
- kfree(kkey);
+ kfree_sensitive(kkey);
if (rc)
break;
if (copy_to_user(utp, &ktp, sizeof(ktp)))
@@ -1640,8 +1639,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
&ktp.protkey.type);
pr_debug("%s pkey_keyblob2pkey2()=%d\n", __func__, rc);
kfree(apqns);
- memzero_explicit(kkey, ktp.keylen);
- kfree(kkey);
+ kfree_sensitive(kkey);
if (rc)
break;
if (copy_to_user(utp, &ktp, sizeof(ktp)))
@@ -1767,8 +1765,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
protkey, &protkeylen, &ktp.pkeytype);
pr_debug("%s pkey_keyblob2pkey3()=%d\n", __func__, rc);
kfree(apqns);
- memzero_explicit(kkey, ktp.keylen);
- kfree(kkey);
+ kfree_sensitive(kkey);
if (rc) {
kfree(protkey);
break;
--
2.43.2



2024-05-08 05:53:45

by Holger Dengler

[permalink] [raw]
Subject: Re: [PATCH v3] s390/pkey: use kfree_sensitive() to fix Coccinelle warnings

On 07/05/2024 23:13, Jules Irenge wrote:
> Replace memzero_explicit() and kfree() with kfree_sentive() to fix
> warnings reported by Coccinelle
>
> WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1506)
> WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1643)
> WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1770)
>
> Signed-off-by: Jules Irenge <[email protected]>

Thanks, looks good to me.
Reviewed-by: Holger Dengler <[email protected]>

--
Mit freundlichen Grüßen / Kind regards
Holger Dengler
--
IBM Systems, Linux on IBM Z Development
[email protected]

2024-05-08 09:00:32

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH v3] s390/pkey: use kfree_sensitive() to fix Coccinelle warnings

On Wed, May 08, 2024 at 07:53:28AM +0200, Holger Dengler wrote:
> On 07/05/2024 23:13, Jules Irenge wrote:
> > Replace memzero_explicit() and kfree() with kfree_sentive() to fix
> > warnings reported by Coccinelle
> >
> > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1506)
> > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1643)
> > WARNING opportunity for kfree_sensitive/kvfree_sensitive (line 1770)
> >
> > Signed-off-by: Jules Irenge <[email protected]>
>
> Thanks, looks good to me.
> Reviewed-by: Holger Dengler <[email protected]>

Applied, thanks!