• Matteo Croce's avatar
    reboot: fix overflow parsing reboot cpu number · 2e021b71
    Matteo Croce authored
    commit df5b0ab3 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: 0000...
    2e021b71
reboot.c 14 KB