Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Vasily Gorbik <gor@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>, Ilya Leoshkevich <iii@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Subject: [PATCH 3/3] s390/boot: Bound command line facility ranges
Date: Thu, 27 Aug 2026 14:01:31 +0200	[thread overview]
Message-ID: <p03-03.gfb54656967a2.ttkffvj@ub.hpns> (raw)
In-Reply-To: <c00-03.ttkffvj@ub.hpns>

The facilities and debug-alternative command line parsers iterate over
inclusive numeric ranges. If a range ends at ULONG_MAX, incrementing the
current value wraps to zero and the loop never terminates. Large finite
out-of-range values also cause unnecessary early boot iterations even
though the bitmap helpers ignore them.

Stop each loop at the size of the bitmap it modifies. This preserves all
meaningful range values while guaranteeing termination.

Fixes: b5e804598d59 ("s390: allow overriding facilities via command line")
Fixes: 15c33a5bc9b8 ("s390/alternatives: Add debug functionality")
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
 arch/s390/boot/alternative.c | 5 +++--
 arch/s390/boot/ipl_parm.c    | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/s390/boot/alternative.c b/arch/s390/boot/alternative.c
index 19ea7934b918..77e8bad560c5 100644
--- a/arch/s390/boot/alternative.c
+++ b/arch/s390/boot/alternative.c
@@ -45,11 +45,12 @@ static void alt_debug_modify(int type, unsigned int nr, bool clear)
 
 static char *alt_debug_parse(int type, char *str)
 {
-	unsigned long val, endval;
+	unsigned long val, endval, limit;
 	char *endp;
 	bool clear;
 	int i;
 
+	limit = type == ALT_TYPE_FACILITY ? MAX_FACILITY_BIT : MAX_MFEATURE_BIT;
 	if (*str == ':') {
 		str++;
 	} else {
@@ -73,7 +74,7 @@ static char *alt_debug_parse(int type, char *str)
 			if (str == endp)
 				break;
 			str = endp;
-			while (val <= endval) {
+			while (val <= endval && val < limit) {
 				alt_debug_modify(type, val, clear);
 				val++;
 			}
diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
index 8aa7639ae0cb..6d8b9d61bcad 100644
--- a/arch/s390/boot/ipl_parm.c
+++ b/arch/s390/boot/ipl_parm.c
@@ -233,7 +233,7 @@ static void modify_fac_list(char *str)
 			if (str == endp)
 				break;
 			str = endp;
-			while (val <= endval) {
+			while (val <= endval && val < MAX_FACILITY_BIT) {
 				modify_facility(val, clear);
 				val++;
 			}
-- 
2.53.0

  parent reply	other threads:[~2026-08-27 12:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 12:01 [PATCH 0/3] s390/boot: Fix couple of early boot edge cases Vasily Gorbik
2026-08-27 12:01 ` [PATCH 1/3] s390/boot: Fix physical memory search range Vasily Gorbik
2026-08-27 12:06   ` sashiko-bot
2026-08-27 13:36   ` Heiko Carstens
2026-08-27 12:01 ` [PATCH 2/3] s390/boot: Avoid IPL parameter append past command line Vasily Gorbik
2026-08-27 12:06   ` sashiko-bot
2026-08-27 13:36   ` Heiko Carstens
2026-08-27 12:01 ` Vasily Gorbik [this message]
2026-08-27 12:09   ` [PATCH 3/3] s390/boot: Bound command line facility ranges sashiko-bot
2026-08-27 13:49   ` Heiko Carstens
2026-08-27 15:59 ` [PATCH 0/3] s390/boot: Fix couple of early boot edge cases Vasily Gorbik

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=p03-03.gfb54656967a2.ttkffvj@ub.hpns \
    --to=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    /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