* [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer
@ 2022-12-06 12:59 Liam Ni
2023-01-07 10:40 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Liam Ni @ 2022-12-06 12:59 UTC (permalink / raw)
To: x86, linux-kernel, linux-arch, linux-efi, linux-doc, linux-mm,
kvm, kasan-dev
Cc: zhiguangni01
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer
2022-12-06 12:59 [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer Liam Ni
@ 2023-01-07 10:40 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2023-01-07 10:40 UTC (permalink / raw)
To: Liam Ni
Cc: x86, linux-kernel, linux-arch, linux-efi, linux-doc, linux-mm,
kvm, kasan-dev
* Liam Ni <zhiguangni01@gmail.com> wrote:
> 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 */
Can this ever happen?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-07 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 12:59 [PATCH] x86/boot: Check if the input parameter (buffer) of the function is a null pointer Liam Ni
2023-01-07 10:40 ` Ingo Molnar
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).