Matteo Croce
0b2a9f794f
reboot: fix overflow parsing reboot cpu number
commit df5b0ab3e08a156701b537809914b339b0daa526 upstream.
Limit the CPU number to num_possible_cpus(), because setting it to a
value lower than INT_MAX but higher than NR_CPUS produces the following
error on reboot and shutdown:
BUG: unable to handle page fault for address: ffffffff90ab1bb0
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 1c09067 P4D 1c09067 PUD 1c0a063 PMD 0
Oops: 0000 [#1] SMP
CPU: 1 PID: 1 Comm: systemd-shutdow Not tainted 5.9.0-rc8-kvm #110
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
RIP: 0010:migrate_to_reboot_cpu+0xe/0x60
Code: ea ea 00 48 89 fa 48 c7 c7 30 57 f1 81 e9 fa ef ff ff 66 2e 0f 1f 84 00 00 00 00 00 53 8b 1d d5 ea ea 00 e8 14 33 fe ff 89 da <48> 0f a3 15 ea fc bd 00 48 89 d0 73 29 89 c2 c1 e8 06 65 48 8b 3c
RSP: 0018:ffffc90000013e08 EFLAGS: 00010246
RAX: ffff88801f0a0000 RBX: 0000000077359400 RCX: 0000000000000000
RDX: 0000000077359400 RSI: 0000000000000002 RDI: ffffffff81c199e0
RBP: ffffffff81c1e3c0 R08: ffff88801f41f000 R09: ffffffff81c1e348
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 00007f32bedf8830 R14: 00000000fee1dead R15: 0000000000000000
FS: 00007f32bedf8980(0000) GS:ffff88801f480000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffff90ab1bb0 CR3: 000000001d057000 CR4: 00000000000006a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__do_sys_reboot.cold+0x34/0x5b
do_syscall_64+0x2d/0x40
Fixes: 1b3a5d02ee ("reboot: move arch/x86 reboot= handling to generic kernel")
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Fabian Frederick <fabf@skynet.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Robin Holt <robinmholt@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20201103214025.116799-3-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>
2020-11-18 18:25:04 +01:00
..
2020-05-10 10:26:19 +02:00
2016-09-24 10:07:42 +02:00
2020-11-10 10:22:13 +01:00
2020-11-18 18:25:04 +01:00
2020-09-23 08:44:26 +02:00
2020-06-03 08:12:14 +02:00
2015-11-11 17:36:04 +01:00
2020-09-03 11:19:24 +02:00
2020-10-29 09:03:09 +01:00
2020-10-01 11:11:56 +02:00
2019-06-11 12:24:04 +02:00
2020-07-22 09:10:07 +02:00
2020-11-18 18:25:02 +01:00
2020-11-18 18:24:57 +01:00
2015-10-21 15:18:35 +01:00
2018-01-10 09:27:08 +01:00
2018-02-16 20:09:45 +01:00
2015-08-06 16:14:53 -04:00
2015-11-04 08:23:51 -05:00
2020-10-01 11:11:52 +02:00
2020-05-02 17:20:48 +02:00
2015-11-04 08:23:51 -05:00
2020-03-11 07:51:13 +01:00
2019-11-28 18:26:01 +01:00
2018-11-21 09:27:35 +01:00
2017-01-06 11:16:14 +01:00
2015-12-03 10:18:21 -05:00
2019-12-21 10:35:24 +01:00
2019-09-06 10:18:11 +02:00
2015-06-04 23:57:18 +02:00
2015-11-10 12:06:23 +01:00
2020-06-20 10:23:24 +02:00
2019-07-10 09:56:36 +02:00
2017-10-12 11:27:35 +02:00
2019-08-04 09:35:01 +02:00
2019-10-17 13:40:56 -07:00
2020-11-18 18:25:01 +01:00
2017-07-21 07:44:56 +02:00
2020-11-10 10:22:20 +01:00
2016-02-25 12:01:16 -08:00
2020-04-24 07:57:13 +02:00
2018-01-10 09:27:10 +01:00
2019-02-20 10:13:14 +01:00
2015-11-23 09:44:58 +01:00
2017-12-16 10:33:55 +01:00
2016-02-25 12:01:16 -08:00
2015-05-12 09:46:00 +02:00
2015-11-06 17:50:42 -08:00
2016-09-24 10:07:36 +02:00
2015-09-10 13:29:01 -07:00
2015-11-06 17:50:42 -08:00
2020-10-14 09:46:22 +02:00
2020-10-01 11:11:58 +02:00
2015-09-10 13:29:01 -07:00
2018-09-09 20:04:34 +02:00
2015-09-11 15:21:34 -07:00
2017-03-12 06:37:26 +01:00
2019-01-13 10:05:32 +01:00
2015-10-21 15:18:36 +01:00
2019-12-21 10:35:38 +01:00
2020-04-02 19:02:31 +02:00
2020-05-27 16:40:27 +02:00
2019-10-17 13:40:58 -07:00
2015-11-09 15:53:39 -08:00
2019-08-04 09:34:42 +02:00
2018-04-13 19:50:03 +02:00
2018-02-25 11:03:44 +01:00
2019-07-10 09:56:42 +02:00
2020-11-18 18:25:04 +01:00
2018-05-30 07:49:00 +02:00
2018-04-24 09:32:05 +02:00
2018-07-25 10:18:27 +02:00
2020-04-24 07:57:12 +02:00
2015-11-06 17:50:42 -08:00
2015-10-20 10:23:55 +02:00
2015-12-12 10:15:34 -08:00
2015-11-05 19:34:48 -08:00
2020-10-01 11:11:51 +02:00
2016-04-12 09:08:58 -07:00
2020-07-09 09:35:08 +02:00
2015-09-05 13:46:58 -07:00
2020-01-12 11:22:40 +01:00
2015-10-06 11:25:01 -07:00
2018-05-16 10:06:47 +02:00
2018-01-10 09:27:10 +01:00
2018-09-09 20:04:35 +02:00
2018-09-09 20:04:35 +02:00
2017-01-06 11:16:16 +01:00
2017-11-15 17:13:11 +01:00
2019-12-21 10:35:37 +01:00