[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211227090917.35838-1-hbh25y@gmail.com>
Date: Mon, 27 Dec 2021 17:09:17 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: geert@...ux-m68k.org
Cc: linux-m68k@...ts.linux-m68k.org, linux-kernel@...r.kernel.org,
Hangyu Hua <hbh25y@...il.com>
Subject: [PATCH] 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.
Signed-off-by: Hangyu Hua <hbh25y@...il.com>
---
arch/m68k/kernel/uboot.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/m68k/kernel/uboot.c b/arch/m68k/kernel/uboot.c
index 928dbd33fc4a..05eca6f653b5 100644
--- a/arch/m68k/kernel/uboot.c
+++ b/arch/m68k/kernel/uboot.c
@@ -101,5 +101,8 @@ __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;
+ else
+ commandp[0] = 0;
}
--
2.25.1
Powered by blists - more mailing lists