* [PATCH] reboot: keep parsed reboot CPU in range
@ 2026-06-22 15:42 Bradley Morgan
2026-06-25 0:46 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Bradley Morgan @ 2026-06-22 15:42 UTC (permalink / raw)
To: Kees Cook
Cc: Andrew Morton, Matteo Croce, linux-kernel, stable, Bradley Morgan
reboot=s... parses the CPU number with simple_strtoul(), but stores
it in an int before checking it against num_possible_cpus(). Very
large values can wrap negative and bypass the range check, leaving
reboot_cpu invalid for migrate_to_reboot_cpu().
Keep the parsed value unsigned until after the range check.
Fixes: f9a90501faac ("reboot: refactor and comment the cpu selection code")
Cc: stable@vger.kernel.org
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
kernel/reboot.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 695c33e75efd..a1ad6047b14a 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1134,12 +1134,11 @@ static int __init reboot_setup(char *str)
str += str[1] == 'm' && str[2] == 'p' ? 3 : 1;
if (isdigit(str[0])) {
- int cpu = simple_strtoul(str, NULL, 0);
+ unsigned long cpu = simple_strtoul(str, NULL, 0);
if (cpu >= num_possible_cpus()) {
- pr_err("Ignoring the CPU number in reboot= option. "
- "CPU %d exceeds possible cpu number %d\n",
- cpu, num_possible_cpus());
+ pr_err("Ignoring the CPU number in reboot= option. CPU %lu exceeds possible cpu number %u\n",
+ cpu, num_possible_cpus());
break;
}
reboot_cpu = cpu;
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] reboot: keep parsed reboot CPU in range
2026-06-22 15:42 [PATCH] reboot: keep parsed reboot CPU in range Bradley Morgan
@ 2026-06-25 0:46 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-06-25 0:46 UTC (permalink / raw)
To: Bradley Morgan; +Cc: Kees Cook, Matteo Croce, linux-kernel, stable
On Mon, 22 Jun 2026 15:42:16 +0000 Bradley Morgan <include@grrlz.net> wrote:
> reboot=s... parses the CPU number with simple_strtoul(), but stores
> it in an int before checking it against num_possible_cpus(). Very
> large values can wrap negative and bypass the range check, leaving
> reboot_cpu invalid for migrate_to_reboot_cpu().
Thanks. kstrtoXX() is the modern way.
> Keep the parsed value unsigned until after the range check.
>
> Fixes: f9a90501faac ("reboot: refactor and comment the cpu selection code")
> Cc: stable@vger.kernel.org
I don't think this is serious enough to warrant backporting.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-25 0:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 15:42 [PATCH] reboot: keep parsed reboot CPU in range Bradley Morgan
2026-06-25 0:46 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox