Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Radu Rendec <rrendec@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Rob Herring <robh@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH] arm64: cacheinfo: Avoid out-of-bounds write to cacheinfo array
Date: Tue, 4 Feb 2025 12:39:56 +0000	[thread overview]
Message-ID: <20250204123955.GD1063@willie-the-truck> (raw)
In-Reply-To: <20250123181159.1849346-1-rrendec@redhat.com>

On Thu, Jan 23, 2025 at 01:11:59PM -0500, Radu Rendec wrote:
> diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
> index d9c9218fa1fdd..77ffda7284754 100644
> --- a/arch/arm64/kernel/cacheinfo.c
> +++ b/arch/arm64/kernel/cacheinfo.c
> @@ -101,16 +101,18 @@ int populate_cache_leaves(unsigned int cpu)
>  	unsigned int level, idx;
>  	enum cache_type type;
>  	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
> -	struct cacheinfo *this_leaf = this_cpu_ci->info_list;
> +	struct cacheinfo *infos = this_cpu_ci->info_list;
>  
>  	for (idx = 0, level = 1; level <= this_cpu_ci->num_levels &&
> -	     idx < this_cpu_ci->num_leaves; idx++, level++) {
> +	     idx < this_cpu_ci->num_leaves; level++) {
>  		type = get_cache_type(level);
>  		if (type == CACHE_TYPE_SEPARATE) {
> -			ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
> -			ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
> +			if (idx + 2 > this_cpu_ci->num_leaves)
> +				break;

Why are you checking 'idx + 2' rather than 'idx + 1'?

Will


  reply	other threads:[~2025-02-04 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 18:11 [PATCH] arm64: cacheinfo: Avoid out-of-bounds write to cacheinfo array Radu Rendec
2025-02-04 12:39 ` Will Deacon [this message]
2025-02-04 15:55   ` Radu Rendec
2025-02-06 13:02     ` Will Deacon
2025-02-06 15:22       ` Radu Rendec

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=20250204123955.GD1063@willie-the-truck \
    --to=will@kernel.org \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=rrendec@redhat.com \
    --cc=sudeep.holla@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox