From: Liam Ni <zhiguangni01@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, linux-efi@vger.kernel.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
kvm@vger.kernel.org, kasan-dev@googlegroups.com
Cc: zhiguangni01@gmail.com
Subject: [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer
Date: Tue, 6 Dec 2022 20:59:29 +0800 [thread overview]
Message-ID: <20221206125929.12237-1-zhiguangni01@gmail.com> (raw)
If the variable buffer is a null pointer, it may cause the kernel to crash.
Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
arch/x86/boot/cmdline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c
index 21d56ae83cdf..d0809f66054c 100644
--- a/arch/x86/boot/cmdline.c
+++ b/arch/x86/boot/cmdline.c
@@ -39,7 +39,7 @@ int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *b
st_bufcpy /* Copying this to buffer */
} state = st_wordstart;
- if (!cmdline_ptr)
+ if (!cmdline_ptr || buffer == NULL)
return -1; /* No command line */
cptr = cmdline_ptr & 0xf;
--
2.25.1
next reply other threads:[~2022-12-06 12:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 12:59 Liam Ni [this message]
2023-01-07 10:40 ` [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer Ingo Molnar
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=20221206125929.12237-1-zhiguangni01@gmail.com \
--to=zhiguangni01@gmail.com \
--cc=kasan-dev@googlegroups.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).