Skip to content

Commit 202e227

Browse files
irengemehmetb0
authored andcommitted
s390/pkey: Use kfree_sensitive() to fix Coccinelle warnings
[ Upstream commit 22e6824 ] Replace memzero_explicit() and kfree() with kfree_sensitive() 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]> Reviewed-by: Holger Dengler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (backported from commit 62151a0acde90823bdfa991d598c85cf4b1d387d linux-6.9.y) [mpellizzer: backported solving merge conflicts caused by surrounding instructions which do not affect the patch] CVE-2024-42158 Signed-off-by: Massimiliano Pellizzer <[email protected]> Acked-by: Guoqing Jiang <[email protected]> Acked-by: Manuel Diewald <[email protected]> Acked-by: Ivan Hu <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 96eb790 commit 202e227

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/s390/crypto/pkey_api.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
12861286
return PTR_ERR(kkey);
12871287
rc = pkey_keyblob2pkey(kkey, ktp.keylen, &ktp.protkey);
12881288
DEBUG_DBG("%s pkey_keyblob2pkey()=%d\n", __func__, rc);
1289-
memzero_explicit(kkey, ktp.keylen);
1290-
kfree(kkey);
1289+
kfree_sensitive(kkey);
12911290
if (rc)
12921291
break;
12931292
if (copy_to_user(utp, &ktp, sizeof(ktp)))
@@ -1420,8 +1419,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
14201419
kkey, ktp.keylen, &ktp.protkey);
14211420
DEBUG_DBG("%s pkey_keyblob2pkey2()=%d\n", __func__, rc);
14221421
kfree(apqns);
1423-
memzero_explicit(kkey, ktp.keylen);
1424-
kfree(kkey);
1422+
kfree_sensitive(kkey);
14251423
if (rc)
14261424
break;
14271425
if (copy_to_user(utp, &ktp, sizeof(ktp)))
@@ -1547,8 +1545,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
15471545
protkey, &protkeylen);
15481546
DEBUG_DBG("%s pkey_keyblob2pkey3()=%d\n", __func__, rc);
15491547
kfree(apqns);
1550-
memzero_explicit(kkey, ktp.keylen);
1551-
kfree(kkey);
1548+
kfree_sensitive(kkey);
15521549
if (rc) {
15531550
kfree(protkey);
15541551
break;

0 commit comments

Comments
 (0)