• R/O
  • HTTP
  • SSH
  • HTTPS

BrynKernel-AOSP: 提交

https://bryn-lab.my.id/kernel.html


Commit MetaInfo

修订版3a4304ca26d70ef4aa5a46035776c4e3ac4acc47 (tree)
时间2020-11-19 02:26:31
作者Matteo Croce <mcroce@micr...>
CommiterGreg Kroah-Hartman

Log Message

Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint"

commit 8b92c4ff4423aa9900cf838d3294fcade4dbda35 upstream.

Patch series "fix parsing of reboot= cmdline", v3.

The parsing of the reboot= cmdline has two major errors:

- a missing bound check can crash the system on reboot
- parsing of the cpu number only works if specified last

Fix both.

This patch (of 2):

This reverts commit 616feab753972b97.

kstrtoint() and simple_strtoul() have a subtle difference which makes
them non interchangeable: if a non digit character is found amid the
parsing, the former will return an error, while the latter will just
stop parsing, e.g. simple_strtoul("123xyx") = 123.

The kernel cmdline reboot= argument allows to specify the CPU used for
rebooting, with the syntax s#### among the other flags, e.g.
"reboot=warm,s31,force", so if this flag is not the last given, it's
silently ignored as well as the subsequent ones.

Fixes: 616feab75397 ("kernel/reboot.c: convert simple_strtoul to kstrtoint")
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Robin Holt <robinmholt@gmail.com>
Cc: Fabian Frederick <fabf@skynet.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20201103214025.116799-2-mcroce@linux.microsoft.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[sudip: use reboot_mode instead of mode]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

更改概述

差异

--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -512,22 +512,15 @@ static int __init reboot_setup(char *str)
512512 break;
513513
514514 case 's':
515- {
516- int rc;
517-
518- if (isdigit(*(str+1))) {
519- rc = kstrtoint(str+1, 0, &reboot_cpu);
520- if (rc)
521- return rc;
522- } else if (str[1] == 'm' && str[2] == 'p' &&
523- isdigit(*(str+3))) {
524- rc = kstrtoint(str+3, 0, &reboot_cpu);
525- if (rc)
526- return rc;
527- } else
515+ if (isdigit(*(str+1)))
516+ reboot_cpu = simple_strtoul(str+1, NULL, 0);
517+ else if (str[1] == 'm' && str[2] == 'p' &&
518+ isdigit(*(str+3)))
519+ reboot_cpu = simple_strtoul(str+3, NULL, 0);
520+ else
528521 reboot_mode = REBOOT_SOFT;
529522 break;
530- }
523+
531524 case 'g':
532525 reboot_mode = REBOOT_GPIO;
533526 break;
Show on old repository browser