Alpha arch development list
 help / color / mirror / Atom feed
* [PATCH] alpha: boot: check OSFLAGS length in start_kernel()
@ 2026-11-19 10:44 Mohamed Salem Gorrab via B4 Relay
  0 siblings, 0 replies; only message in thread
From: Mohamed Salem Gorrab via B4 Relay @ 2026-11-19 10:44 UTC (permalink / raw)
  To: Richard Henderson, Matt Turner, Magnus Lindholm
  Cc: linux-alpha, Mohamed Salem Gorrab

From: Mohamed Salem Gorrab <grghdghhhh@gmail.com>

bootp.c and bootpz.c reject a length >= sizeof(envval) from
callback_getenv() before writing the terminating NUL. main.c only
rejects negative values, so a return value of 256 would write one
byte past the end of envval.

Use the same check as the other two files. I don't know whether the
SRM firmware can actually return a length equal to the buffer size,
so this is mainly for consistency. I have not tested on Alpha
hardware.

Signed-off-by: Mohamed Salem Gorrab <grghdghhhh@gmail.com>
---
 arch/alpha/boot/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/alpha/boot/main.c b/arch/alpha/boot/main.c
index 22a1cb0264afe6397ef2598c107f88280b979d63..0ce301edb219dc0c2fbabe5f692b48437a79d3b1 100644
--- a/arch/alpha/boot/main.c
+++ b/arch/alpha/boot/main.c
@@ -176,7 +176,7 @@ void start_kernel(void)
 	}
 
 	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
-	if (nbytes < 0) {
+	if (nbytes < 0 || nbytes >= sizeof(envval)) {
 		nbytes = 0;
 	}
 	envval[nbytes] = '\0';

---
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
change-id: 20261119-alpha-osflags-d51e88f028b3

Best regards,
-- 
Mohamed Salem Gorrab <grghdghhhh@gmail.com>



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19 10:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 10:44 [PATCH] alpha: boot: check OSFLAGS length in start_kernel() Mohamed Salem Gorrab via B4 Relay

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