Skip to contentSkip to conversation

m68k/kernel: array out of bound access in process_uboot_commandline

PATCH Superseded Hangyu Hua 2 participants 3 messages Dec 28, 2021 – Jan 4, 2022 m68k architecture

lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH v2 1/1 m68k/kernel: array out of bound access in process_uboot_commandline

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

---
 arch/m68k/kernel/uboot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/uboot.c +2 -1
index 928dbd33fc4a..63eaf3c3ddcd 100644
@@ -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;
 }
Signature · 1 line
2.25.1
#1 lore raw

CC greg

Quoted 23 lines · Hangyu Hua

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

---
 arch/m68k/kernel/uboot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/uboot.c +2 -2
index 928dbd33fc4a..63eaf3c3ddcd 100644
@@ -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

author
#2 lore raw

Hi, I think this patch may be forgotten. So I send this e-mail. And I cc Andreas
who helped me fix the initial version of this patch.

Happy new year.

Quoted 27 lines · Geert Uytterhoeven

CC greg

Quoted 23 lines · Hangyu Hua

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

---
 arch/m68k/kernel/uboot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/uboot.c +2 -2
index 928dbd33fc4a..63eaf3c3ddcd 100644
@@ -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