Alpha arch development list
 help / color / mirror / Atom feed
From: Mohamed Salem Gorrab via B4 Relay <devnull+grghdghhhh.gmail.com@kernel.org>
To: Richard Henderson <richard.henderson@linaro.org>,
	 Matt Turner <mattst88@gmail.com>,
	Magnus Lindholm <linmag7@gmail.com>
Cc: linux-alpha@vger.kernel.org,
	 Mohamed Salem Gorrab <grghdghhhh@gmail.com>
Subject: [PATCH] alpha: boot: check OSFLAGS length in start_kernel()
Date: Thu, 19 Nov 2026 05:44:04 -0500	[thread overview]
Message-ID: <20261119-alpha-osflags-v1-1-b5f58d1cbdf8@gmail.com> (raw)

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>



                 reply	other threads:[~2026-11-19 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261119-alpha-osflags-v1-1-b5f58d1cbdf8@gmail.com \
    --to=devnull+grghdghhhh.gmail.com@kernel.org \
    --cc=grghdghhhh@gmail.com \
    --cc=linmag7@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.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