lkml.org 
[lkml]   [2014]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: kernel: clockevents: shift out-of-bounds
    On Mon, Oct 20, 2014 at 03:07:50PM +0400, Andrey Ryabinin wrote:
    >
    > 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)))

    Probably so indeed, clocks_calc_mult_shift() has max return value of 32,
    which will indeed trigger that overflow.


    \
     
     \ /
      Last update: 2014-10-24 13:01    [W:2.573 / U:0.176 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site