From: Kathara Sasikumar <katharasasikumar007@gmail.com>
To: richard.henderson@linaro.org
Cc: mattst88@gmail.com, linmag7@gmail.com,
david.hunter.linux@gmail.com, linux-alpha@vger.kernel.org,
linux-kernel@vger.kernel.org, shuah@kernel.org,
skhan@linuxfoundation.org, katharasasikumar007@gmail.com
Subject: [PATCH] alpha/boot: replace strcpy() with strscpy() when copying envval
Date: Fri, 5 Dec 2025 18:03:54 +0000 [thread overview]
Message-ID: <20251205180354.621925-1-katharasasikumar007@gmail.com> (raw)
strcpy() does not check the size of the destination buffer and is
deprecated in the kernel as documented in
Documentation/process/deprecated.rst. ZERO_PGE is PAGE_SIZE bytes, so
using strscpy() with PAGE_SIZE makes the copy safe and avoids any risk
of overflow.
No functional change intended.
Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com>
---
arch/alpha/boot/bootp.c | 2 +-
arch/alpha/boot/main.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/alpha/boot/bootp.c b/arch/alpha/boot/bootp.c
index 842e85776cc0..e0b411ded992 100644
--- a/arch/alpha/boot/bootp.c
+++ b/arch/alpha/boot/bootp.c
@@ -204,7 +204,7 @@ start_kernel(void)
load(START_ADDR, START_ADDR+(4*KERNEL_SIZE), KERNEL_SIZE);
memset((char*)ZERO_PGE, 0, PAGE_SIZE);
- strcpy((char*)ZERO_PGE, envval);
+ strscpy((char *)ZERO_PGE, envval, PAGE_SIZE);
#ifdef INITRD_IMAGE_SIZE
((long *)(ZERO_PGE+256))[0] = initrd_start;
((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;
diff --git a/arch/alpha/boot/main.c b/arch/alpha/boot/main.c
index 22a1cb0264af..7ec728c037d8 100644
--- a/arch/alpha/boot/main.c
+++ b/arch/alpha/boot/main.c
@@ -180,7 +180,7 @@ void start_kernel(void)
nbytes = 0;
}
envval[nbytes] = '\0';
- strcpy((char*)ZERO_PGE, envval);
+ strscpy((char *)ZERO_PGE, envval, PAGE_SIZE);
srm_printk(" Ok\nNow booting the kernel\n");
runkernel();
--
2.51.0
reply other threads:[~2025-12-05 18:06 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=20251205180354.621925-1-katharasasikumar007@gmail.com \
--to=katharasasikumar007@gmail.com \
--cc=david.hunter.linux@gmail.com \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=richard.henderson@linaro.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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