From: Kees Cook <kees@kernel.org>
To: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Alexander Potapenko <glider@google.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
Timothy Hayes <timothy.hayes@arm.com>,
Sascha Bischoff <Sascha.Bischoff@arm.com>,
Keir Fraser <keirf@google.com>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: vgic: Handle const qualifier from clusters allocation type
Date: Fri, 6 Feb 2026 14:29:40 -0800 [thread overview]
Message-ID: <202602061429.4FB68A777@keescook> (raw)
In-Reply-To: <20260206222651.work.438-kees@kernel.org>
Oops, bad Subject... sending v2
On Fri, Feb 06, 2026 at 02:26:53PM -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().
>
> 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
>
--
Kees Cook
prev parent reply other threads:[~2026-02-06 22:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 22:26 [PATCH] KVM: arm64: vgic: Handle const qualifier from clusters allocation type Kees Cook
2026-02-06 22:29 ` Kees Cook [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202602061429.4FB68A777@keescook \
--to=kees@kernel.org \
--cc=Sascha.Bischoff@arm.com \
--cc=catalin.marinas@arm.com \
--cc=glider@google.com \
--cc=joey.gouly@arm.com \
--cc=keirf@google.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=timothy.hayes@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.