Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj()
@ 2026-08-30 10:17 Manuel Ebner
  2026-08-31 20:41 ` Eric Biggers
  2026-09-02 20:17 ` Kees Cook
  0 siblings, 2 replies; 4+ messages in thread
From: Manuel Ebner @ 2026-08-30 10:17 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
	Cheng-Yang Chou, Eric Biggers
  Cc: Manuel Ebner, Kees Cook, linux-crypto, linux-arm-kernel,
	linux-kernel

Convert to type aware allocation as suggested in commit 2932ba8d9c99
("slab: Introduce kmalloc_obj() and family")

CC: Kees Cook <kees@kernel.org>
Fixes: 652a3017c485 ("crypto: arm64/aes-neonbs - Move key expansion off the stack")
Signed-off-by: Manuel Ebner <manuelebnerli@mailbox.org>
---
I have a couple similar patches lined up but they could be automated or maybe
the script is already made by Kees.
Kees can you make a script assisted commit (again)?
---
 arch/arm64/crypto/aes-neonbs-glue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/crypto/aes-neonbs-glue.c b/arch/arm64/crypto/aes-neonbs-glue.c
index 5bcbac979..7cb1aede9 100644
--- a/arch/arm64/crypto/aes-neonbs-glue.c
+++ b/arch/arm64/crypto/aes-neonbs-glue.c
@@ -66,7 +66,7 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
 	struct crypto_aes_ctx *rk;
 	int err;
 
-	rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+	rk = kmalloc_obj(*rk);
 	if (!rk)
 		return -ENOMEM;
 
@@ -128,7 +128,7 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
 	struct crypto_aes_ctx *rk;
 	int err;
 
-	rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+	rk = kmalloc_obj(*rk);
 	if (!rk)
 		return -ENOMEM;
 
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj()
  2026-08-30 10:17 [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj() Manuel Ebner
@ 2026-08-31 20:41 ` Eric Biggers
  2026-09-02 20:17 ` Kees Cook
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2026-08-31 20:41 UTC (permalink / raw)
  To: Manuel Ebner
  Cc: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
	Cheng-Yang Chou, Kees Cook, linux-crypto, linux-arm-kernel,
	linux-kernel

On Sun, Aug 30, 2026 at 12:17:14PM +0200, Manuel Ebner wrote:
> Convert to type aware allocation as suggested in commit 2932ba8d9c99
> ("slab: Introduce kmalloc_obj() and family")
> 
> CC: Kees Cook <kees@kernel.org>
> Fixes: 652a3017c485 ("crypto: arm64/aes-neonbs - Move key expansion off the stack")
> Signed-off-by: Manuel Ebner <manuelebnerli@mailbox.org>

Please don't use the Fixes tag for behavior-preserving conversions like
this.

- Eric


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj()
  2026-08-30 10:17 [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj() Manuel Ebner
  2026-08-31 20:41 ` Eric Biggers
@ 2026-09-02 20:17 ` Kees Cook
  2026-09-03  7:36   ` Manuel Ebner
  1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2026-09-02 20:17 UTC (permalink / raw)
  To: Manuel Ebner
  Cc: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
	Cheng-Yang Chou, Eric Biggers, linux-crypto, linux-arm-kernel,
	linux-kernel

On Sun, Aug 30, 2026 at 12:17:14PM +0200, Manuel Ebner wrote:
> I have a couple similar patches lined up but they could be automated or maybe
> the script is already made by Kees.
> Kees can you make a script assisted commit (again)?

This lead me down quite a long path to try to figure out why the existing
Coccinelle script (scripts/coccinelle/api/kmalloc_objs.cocci) didn't
catch these. The answer is the cleanup.h macros and poor interaction
with Coccinelle. I think I've got a work-around built now, and I'll send
a new tree-wide change to Linus before -rc2 gets cut.

Thanks for noticing these got missed!

-Kees

-- 
Kees Cook


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj()
  2026-09-02 20:17 ` Kees Cook
@ 2026-09-03  7:36   ` Manuel Ebner
  0 siblings, 0 replies; 4+ messages in thread
From: Manuel Ebner @ 2026-09-03  7:36 UTC (permalink / raw)
  To: Kees Cook
  Cc: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
	Cheng-Yang Chou, Eric Biggers, linux-crypto, linux-arm-kernel,
	linux-kernel

On Wed, 2026-09-02 at 13:17 -0700, Kees Cook wrote:
> On Sun, Aug 30, 2026 at 12:17:14PM +0200, Manuel Ebner wrote:
> > I have a couple similar patches lined up but they could be automated or maybe
> > the script is already made by Kees.
> > Kees can you make a script assisted commit (again)?
> 
> This lead me down quite a long path to try to figure out why the existing
> Coccinelle script (scripts/coccinelle/api/kmalloc_objs.cocci) didn't
> catch these. The answer is the cleanup.h macros and poor interaction
> with Coccinelle. I think I've got a work-around built now, and I'll send
> a new tree-wide change to Linus before -rc2 gets cut.
> 
> Thanks for noticing these got missed!

I think they got introduced after the big '+_obj' commit, this commit 652a3017c485
("crypto: arm64/aes-neonbs - Move key expansion off the stack") is from Mar 6 2026.

I did git checkout this commit and run checkpatch.pl (from Mar 6) over the commit:

WARNING: Prefer kmalloc_obj over kmalloc with sizeof
#37: FILE: arch/arm64/crypto/aes-neonbs-glue.c:82:
+       rk = kmalloc(sizeof(*rk), GFP_KERNEL);

So the recommended workflow should have caught this.

Thanks for handling this.
 Manuel

> -Kees


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-03  7:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 10:17 [PATCH] crypto: arm64/aes-neonbs: transition to kmalloc_obj() Manuel Ebner
2026-08-31 20:41 ` Eric Biggers
2026-09-02 20:17 ` Kees Cook
2026-09-03  7:36   ` Manuel Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox