|
Petr Mladek |
45d71b |
From 8b92c4ff4423aa9900cf838d3294fcade4dbda35 Mon Sep 17 00:00:00 2001
|
|
Petr Mladek |
45d71b |
From: Matteo Croce <mcroce@microsoft.com>
|
|
Petr Mladek |
45d71b |
Date: Fri, 13 Nov 2020 22:52:02 -0800
|
|
Petr Mladek |
45d71b |
Subject: [PATCH] Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint"
|
|
Petr Mladek |
45d71b |
References: bsc#1179418
|
|
Petr Mladek |
45d71b |
Git-commit: 8b92c4ff4423aa9900cf838d3294fcade4dbda35
|
|
Petr Mladek |
45d71b |
Patch-mainline: v5.10-rc4
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
Patch series "fix parsing of reboot= cmdline", v3.
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
The parsing of the reboot= cmdline has two major errors:
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
- a missing bound check can crash the system on reboot
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
- parsing of the cpu number only works if specified last
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
Fix both.
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
This patch (of 2):
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
This reverts commit 616feab753972b97.
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
kstrtoint() and simple_strtoul() have a subtle difference which makes
|
|
Petr Mladek |
45d71b |
them non interchangeable: if a non digit character is found amid the
|
|
Petr Mladek |
45d71b |
parsing, the former will return an error, while the latter will just
|
|
Petr Mladek |
45d71b |
stop parsing, e.g. simple_strtoul("123xyx") = 123.
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
The kernel cmdline reboot= argument allows to specify the CPU used for
|
|
Petr Mladek |
45d71b |
rebooting, with the syntax `s####` among the other flags, e.g.
|
|
Petr Mladek |
45d71b |
"reboot=warm,s31,force", so if this flag is not the last given, it's
|
|
Petr Mladek |
45d71b |
silently ignored as well as the subsequent ones.
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
Fixes: 616feab75397 ("kernel/reboot.c: convert simple_strtoul to kstrtoint")
|
|
Petr Mladek |
45d71b |
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
|
|
Petr Mladek |
45d71b |
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
|
|
Petr Mladek |
45d71b |
Cc: Guenter Roeck <linux@roeck-us.net>
|
|
Petr Mladek |
45d71b |
Cc: Petr Mladek <pmladek@suse.com>
|
|
Petr Mladek |
45d71b |
Cc: Arnd Bergmann <arnd@arndb.de>
|
|
Petr Mladek |
45d71b |
Cc: Mike Rapoport <rppt@kernel.org>
|
|
Petr Mladek |
45d71b |
Cc: Kees Cook <keescook@chromium.org>
|
|
Petr Mladek |
45d71b |
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
|
|
Petr Mladek |
45d71b |
Cc: Robin Holt <robinmholt@gmail.com>
|
|
Petr Mladek |
45d71b |
Cc: Fabian Frederick <fabf@skynet.be>
|
|
Petr Mladek |
45d71b |
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
Petr Mladek |
45d71b |
Cc: <stable@vger.kernel.org>
|
|
Petr Mladek |
45d71b |
Link: https://lkml.kernel.org/r/20201103214025.116799-2-mcroce@linux.microsoft.com
|
|
Petr Mladek |
45d71b |
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
|
Petr Mladek |
45d71b |
Acked-by: Petr Mladek <pmladek@suse.com>
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
---
|
|
Petr Mladek |
45d71b |
kernel/reboot.c | 21 +++++++--------------
|
|
Petr Mladek |
45d71b |
1 file changed, 7 insertions(+), 14 deletions(-)
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
--- a/kernel/reboot.c
|
|
Petr Mladek |
45d71b |
+++ b/kernel/reboot.c
|
|
Petr Mladek |
45d71b |
@@ -512,22 +512,15 @@ static int __init reboot_setup(char *str
|
|
Petr Mladek |
45d71b |
break;
|
|
Petr Mladek |
45d71b |
|
|
Petr Mladek |
45d71b |
case 's':
|
|
Petr Mladek |
45d71b |
- {
|
|
Petr Mladek |
45d71b |
- int rc;
|
|
Petr Mladek |
45d71b |
-
|
|
Petr Mladek |
45d71b |
- if (isdigit(*(str+1))) {
|
|
Petr Mladek |
45d71b |
- rc = kstrtoint(str+1, 0, &reboot_cpu);
|
|
Petr Mladek |
45d71b |
- if (rc)
|
|
Petr Mladek |
45d71b |
- return rc;
|
|
Petr Mladek |
45d71b |
- } else if (str[1] == 'm' && str[2] == 'p' &&
|
|
Petr Mladek |
45d71b |
- isdigit(*(str+3))) {
|
|
Petr Mladek |
45d71b |
- rc = kstrtoint(str+3, 0, &reboot_cpu);
|
|
Petr Mladek |
45d71b |
- if (rc)
|
|
Petr Mladek |
45d71b |
- return rc;
|
|
Petr Mladek |
45d71b |
- } else
|
|
Petr Mladek |
45d71b |
+ if (isdigit(*(str+1)))
|
|
Petr Mladek |
45d71b |
+ reboot_cpu = simple_strtoul(str+1, NULL, 0);
|
|
Petr Mladek |
45d71b |
+ else if (str[1] == 'm' && str[2] == 'p' &&
|
|
Petr Mladek |
45d71b |
+ isdigit(*(str+3)))
|
|
Petr Mladek |
45d71b |
+ reboot_cpu = simple_strtoul(str+3, NULL, 0);
|
|
Petr Mladek |
45d71b |
+ else
|
|
Petr Mladek |
45d71b |
reboot_mode = REBOOT_SOFT;
|
|
Petr Mladek |
45d71b |
break;
|
|
Petr Mladek |
45d71b |
- }
|
|
Petr Mladek |
45d71b |
+
|
|
Petr Mladek |
45d71b |
case 'g':
|
|
Petr Mladek |
45d71b |
reboot_mode = REBOOT_GPIO;
|
|
Petr Mladek |
45d71b |
break;
|