public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* [PATCH v2 RESEND] m68k/kernel: array out of bound access in process_uboot_commandline
@ 2022-01-13  1:58 Hangyu Hua
  2022-01-17  4:03 ` Greg Ungerer
  0 siblings, 1 reply; 5+ messages in thread
From: Hangyu Hua @ 2022-01-13  1:58 UTC (permalink / raw)
  To: geert; +Cc: schwab, gerg, linux-m68k, linux-kernel, Hangyu Hua

When the size of commandp >= size, array out of bound write occurs because
len == 0.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 arch/m68k/kernel/uboot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/kernel/uboot.c b/arch/m68k/kernel/uboot.c
index 928dbd33fc4a..63eaf3c3ddcd 100644
--- a/arch/m68k/kernel/uboot.c
+++ b/arch/m68k/kernel/uboot.c
@@ -101,5 +101,6 @@ __init void process_uboot_commandline(char *commandp, int size)
 	}
 
 	parse_uboot_commandline(commandp, len);
-	commandp[len - 1] = 0;
+	if (len > 0)
+		commandp[len - 1] = 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
[parent not found: <9775e266-5fee-b0e9-7fa3-b602ec4b7796 () gmail ! com>]

end of thread, other threads:[~2022-01-18 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-13  1:58 [PATCH v2 RESEND] m68k/kernel: array out of bound access in process_uboot_commandline Hangyu Hua
2022-01-17  4:03 ` Greg Ungerer
2022-01-18  2:18   ` Hangyu Hua
     [not found] <9775e266-5fee-b0e9-7fa3-b602ec4b7796 () gmail ! com>
2022-01-18  8:26 ` Greg Ungerer
2022-01-18 10:40   ` Hangyu Hua

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