All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brad Hawthorne <brad@sim.vu>
To: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org
Cc: vladimir.murzin@arm.com, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] ARM: NOMMU: pmsa-v7: Fix off-by-one in mpu_setup_region()
Date: Tue, 24 Nov 2026 20:57:55 -0600	[thread overview]
Message-ID: <20261125025757.1159931-4-brad@sim.vu> (raw)
In-Reply-To: <20261125025757.1159931-1-brad@sim.vu>

mpu_setup_region() rejects "number > mpu_max_regions", which lets
number == mpu_max_regions through. Regions are numbered from 0, so
that number names a region the MPU does not have. Reject it too.

Now that allocate_region() respects its limit, no caller passes that
number. Tested under QEMU (mps2-an385): no change in behaviour.

This patch was written with an AI coding assistant (Claude Opus 5.5,
Anthropic): it found the bug in review, wrote the fix, the QEMU tests
and this changelog, and ran them; I reviewed the reasoning and the test
results.

Fixes: 5ad7dcbe40ae ("ARM: mpu: add MPU probe and initialisation functions in C")
Signed-off-by: Brad Hawthorne <brad@sim.vu>
---
 arch/arm/mm/pmsa-v7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/pmsa-v7.c b/arch/arm/mm/pmsa-v7.c
index f2ad0f3ff480..af0c71135a6e 100644
--- a/arch/arm/mm/pmsa-v7.c
+++ b/arch/arm/mm/pmsa-v7.c
@@ -371,7 +371,7 @@ static int __init mpu_setup_region(unsigned int number, phys_addr_t start,
 	u32 size_data;
 
 	/* We kept a region free for probing resolution of MPU regions*/
-	if (number > mpu_max_regions
+	if (number >= mpu_max_regions
 	    || number >= MPU_MAX_REGIONS)
 		return -ENOENT;
 
-- 
2.43.0


  parent reply	other threads:[~2026-11-25  2:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  2:57 [PATCH 0/5] ARM: NOMMU: fix PMSAv7/v8 MPU setup on M-class Brad Hawthorne
2026-11-25  2:57 ` [PATCH 1/5] ARM: NOMMU: pmsa-v7: Do not probe the region order " Brad Hawthorne
2026-11-25 13:12   ` Vladimir Murzin
2026-11-25  2:57 ` [PATCH 2/5] ARM: NOMMU: pmsa-v7: Do not allocate more RAM regions than the limit Brad Hawthorne
2026-11-25 13:16   ` Vladimir Murzin
2026-11-25  2:57 ` Brad Hawthorne [this message]
2026-11-25 13:18   ` [PATCH 3/5] ARM: NOMMU: pmsa-v7: Fix off-by-one in mpu_setup_region() Vladimir Murzin
2026-11-25  2:57 ` [PATCH 4/5] ARM: NOMMU: pmsa-v7: Align a split region's base to its size Brad Hawthorne
2026-11-25 14:16   ` Vladimir Murzin
2026-11-25  2:57 ` [PATCH 5/5] ARM: NOMMU: pmsa-v8: Fix off-by-one in __pmsav8_setup_region() Brad Hawthorne
2026-11-25 13:20   ` Vladimir Murzin
2026-11-25  7:46 ` [PATCH 0/5] ARM: NOMMU: fix PMSAv7/v8 MPU setup on M-class Arnd Bergmann
2026-11-25 14:36 ` Vladimir Murzin

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=20261125025757.1159931-4-brad@sim.vu \
    --to=brad@sim.vu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=vladimir.murzin@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 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.