public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
@ 2026-02-06 22:30 Kees Cook
  2026-02-13 15:03 ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2026-02-06 22:30 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Kees Cook, Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Catalin Marinas, Will Deacon, Alexander Potapenko,
	linux-arm-kernel, kvmarm, Timothy Hayes, Sascha Bischoff,
	Keir Fraser, linux-kernel, linux-hardening

In preparation for making the kmalloc family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type is "struct gic_kvm_info", but the returned type,
while matching, is const qualified. To get them exactly matching, just
use the dereferenced pointer for the sizeof().

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Zenghui Yu <yuzenghui@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: <kvmarm@lists.linux.dev>
---
 arch/arm64/kvm/vgic/vgic-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
index 86c149537493..a53f93546aa0 100644
--- a/arch/arm64/kvm/vgic/vgic-init.c
+++ b/arch/arm64/kvm/vgic/vgic-init.c
@@ -654,7 +654,7 @@ static struct gic_kvm_info *gic_kvm_info;
 void __init vgic_set_kvm_info(const struct gic_kvm_info *info)
 {
 	BUG_ON(gic_kvm_info != NULL);
-	gic_kvm_info = kmalloc(sizeof(*info), GFP_KERNEL);
+	gic_kvm_info = kmalloc(sizeof(*gic_kvm_info), GFP_KERNEL);
 	if (gic_kvm_info)
 		*gic_kvm_info = *info;
 }
-- 
2.34.1



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

* Re: [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
  2026-02-06 22:30 [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type Kees Cook
@ 2026-02-13 15:03 ` Marc Zyngier
  2026-02-25 20:40   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2026-02-13 15:03 UTC (permalink / raw)
  To: Kees Cook
  Cc: Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Catalin Marinas, Will Deacon, Alexander Potapenko,
	linux-arm-kernel, kvmarm, Timothy Hayes, Sascha Bischoff,
	Keir Fraser, linux-kernel, linux-hardening

On Fri, 06 Feb 2026 14:30:23 -0800, Kees Cook wrote:
> In preparation for making the kmalloc family of allocators type aware,
> we need to make sure that the returned type from the allocation matches
> the type of the variable being assigned. (Before, the allocator would
> always return "void *", which can be implicitly cast to any pointer type.)
> 
> The assigned type is "struct gic_kvm_info", but the returned type,
> while matching, is const qualified. To get them exactly matching, just
> use the dereferenced pointer for the sizeof().
> 
> [...]

Applied to fixes, thanks!

[1/1] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
      commit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.




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

* Re: [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
  2026-02-13 15:03 ` Marc Zyngier
@ 2026-02-25 20:40   ` Kees Cook
  2026-02-25 21:10     ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2026-02-25 20:40 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Catalin Marinas, Will Deacon, Alexander Potapenko,
	linux-arm-kernel, kvmarm, Timothy Hayes, Sascha Bischoff,
	Keir Fraser, linux-kernel, linux-hardening

On Fri, Feb 13, 2026 at 03:03:24PM +0000, Marc Zyngier wrote:
> On Fri, 06 Feb 2026 14:30:23 -0800, Kees Cook wrote:
> > In preparation for making the kmalloc family of allocators type aware,
> > we need to make sure that the returned type from the allocation matches
> > the type of the variable being assigned. (Before, the allocator would
> > always return "void *", which can be implicitly cast to any pointer type.)
> > 
> > The assigned type is "struct gic_kvm_info", but the returned type,
> > while matching, is const qualified. To get them exactly matching, just
> > use the dereferenced pointer for the sizeof().
> > 
> > [...]
> 
> Applied to fixes, thanks!
> 
> [1/1] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
>       commit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1

Just a heads-up that I ended up sending this patch to Linus for -rc1 as
it was a prerequisite for the tree-wide kmalloc_obj refactoring. Sorry
for any merge conflicts this might create for your tree! It is now
commit c732084c891d there.

-- 
Kees Cook


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

* Re: [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
  2026-02-25 20:40   ` Kees Cook
@ 2026-02-25 21:10     ` Marc Zyngier
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2026-02-25 21:10 UTC (permalink / raw)
  To: Kees Cook
  Cc: Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Catalin Marinas, Will Deacon, Alexander Potapenko,
	linux-arm-kernel, kvmarm, Timothy Hayes, Sascha Bischoff,
	Keir Fraser, linux-kernel, linux-hardening

On Wed, 25 Feb 2026 20:40:59 +0000,
Kees Cook <kees@kernel.org> wrote:
> 
> On Fri, Feb 13, 2026 at 03:03:24PM +0000, Marc Zyngier wrote:
> > On Fri, 06 Feb 2026 14:30:23 -0800, Kees Cook wrote:
> > > In preparation for making the kmalloc family of allocators type aware,
> > > we need to make sure that the returned type from the allocation matches
> > > the type of the variable being assigned. (Before, the allocator would
> > > always return "void *", which can be implicitly cast to any pointer type.)
> > > 
> > > The assigned type is "struct gic_kvm_info", but the returned type,
> > > while matching, is const qualified. To get them exactly matching, just
> > > use the dereferenced pointer for the sizeof().
> > > 
> > > [...]
> > 
> > Applied to fixes, thanks!
> > 
> > [1/1] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
> >       commit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1
> 
> Just a heads-up that I ended up sending this patch to Linus for -rc1 as
> it was a prerequisite for the tree-wide kmalloc_obj refactoring. Sorry
> for any merge conflicts this might create for your tree! It is now
> commit c732084c891d there.

Yup, I noticed it this morning as I was preparing the first batch of
fixes for KVM/arm64.

I'd appreciate it if in the future you would let me know upfront what
route you expect a given patch to take -- I'll happily give an ack for
a patch you want to route directly to Linus, rather than carrying it
and ending up with conflicts with upstream.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.


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

end of thread, other threads:[~2026-02-25 21:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06 22:30 [PATCH v2] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type Kees Cook
2026-02-13 15:03 ` Marc Zyngier
2026-02-25 20:40   ` Kees Cook
2026-02-25 21:10     ` Marc Zyngier

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