History

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

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.

Matteo Croce committed 6 years ago

Commit 8b92c4f1 parent 3347acc1 file · +7 −14Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/reboot.c+7−14
@@ -551,22 +551,15 @@ static int __init reboot_setup(char *str) · 550 unmodified lines
551551 break;
552552
553553 case 's':
554− {
555− int rc;
556−
557− if (isdigit(*(str+1))) {
558− rc = kstrtoint(str+1, 0, &reboot_cpu);
559− if (rc)
560− return rc;
561− } else if (str[1] == 'm' && str[2] == 'p' &&
562− isdigit(*(str+3))) {
563− rc = kstrtoint(str+3, 0, &reboot_cpu);
564− if (rc)
565− return rc;
566− } else
554+ if (isdigit(*(str+1)))
555+ reboot_cpu = simple_strtoul(str+1, NULL, 0);
556+ else if (str[1] == 'm' && str[2] == 'p' &&
557+ isdigit(*(str+3)))
558+ reboot_cpu = simple_strtoul(str+3, NULL, 0);
559+ else
567560 *mode = REBOOT_SOFT;
568561 break;
569− }
562+
570563 case 'g':
571564 *mode = REBOOT_GPIO;
572565 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t