kernel: clockevents: shift out-of-bounds
From: Andrey Ryabinin
Date: Mon Oct 20 2014 - 07:08:02 EST
On kernel with UBSan enabled I've got following:
UBSan: Undefined behaviour in ../kernel/time/clockevents.c:75:34
shift exponent 32 is to large for 32-bit type 'unsigned int'
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.17.0-rc7+ #39
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014
0000000000000000 0000000000000000 0000000000000001 ffffffff83003db0
ffffffff82a30940 0000000000000020 ffffffff83003dc0 ffffffff819502e9
ffffffff83003e40 ffffffff81950735 ffff88013f003233 0000000000000000
Call Trace:
dump_stack (/home/andrew/linux/lib/dump_stack.c:52)
ubsan_epilogue (/home/andrew/linux/lib/ubsan.c:122)
__ubsan_handle_shift_out_of_bounds (/home/andrew/linux/lib/ubsan.c:390)
? hpet_enable (/home/andrew/linux/arch/x86/kernel/hpet.c:862)
cev_delta2ns (/home/andrew/linux/kernel/time/clockevents.c:75 (discriminator 1))
clockevents_config.part.2 (/home/andrew/linux/kernel/time/clockevents.c:421)
? __clocksource_select (/home/andrew/linux/kernel/time/clocksource.c:607 /home/andrew/linux/kernel/time/clocksource.c:631)
clockevents_config_and_register (/home/andrew/linux/kernel/time/clockevents.c:440)
hpet_enable (/home/andrew/linux/arch/x86/kernel/hpet.c:305 /home/andrew/linux/arch/x86/kernel/hpet.c:891)
hpet_time_init (/home/andrew/linux/arch/x86/kernel/time.c:79)
x86_late_time_init (/home/andrew/linux/arch/x86/kernel/time.c:87)
start_kernel (/home/andrew/linux/init/main.c:637)
? early_idt_handlers (/home/andrew/linux/arch/x86/kernel/head_64.S:344)
x86_64_start_reservations (/home/andrew/linux/arch/x86/kernel/head64.c:194)
x86_64_start_kernel (/home/andrew/linux/arch/x86/kernel/head64.c:183)
I guess it should be 1ULL here instead of 1U:
(!ismax || evt->mult <= (1U << evt->shift)))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/