Re: [net] 6ef3f95797: UBSAN:shift-out-of-bounds_in_kernel/time/timer.c

From: Artem Savkov
Date: Sat Apr 02 2022 - 03:11:21 EST


On Sat, Apr 02, 2022 at 11:09:40AM +0800, kernel test robot wrote:
>
>
> Greeting,
>
> FYI, we noticed the following commit (built with gcc-9):
>
> commit: 6ef3f95797546781829db3bb6228c9990ba1d49f ("[PATCH v3 2/2] net: make tcp keepalive timer upper bound")
> url: https://github.com/intel-lab-lkp/linux/commits/Artem-Savkov/timer-add-a-function-to-adjust-timeouts-to-be-upper-bound/20220330-172140
> base: https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git b166e52541f2357ce126a92ce1d9a580fdca719d
> patch link: https://lore.kernel.org/netdev/20220330082046.3512424-3-asavkov@xxxxxxxxxx
>
> in testcase: kernel-selftests
> version: kernel-selftests-x86_64-a17aac1b-1_20220328
> with following parameters:
>
> group: tc-testing
> ucode: 0xec
>
> test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
> test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
>
>
> on test machine: 8 threads Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz with 16G memory
>
> caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
>
>
>
> If you fix the issue, kindly add following tag
> Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
>
>
> [ 158.913672][ C1] UBSAN: shift-out-of-bounds in kernel/time/timer.c:584:32
> [ 158.922603][ C1] shift exponent -3 is negative

This is caused by LVL_START(0). Levels 0 and 1 need to be handled
separately to insure we don't end up with negative values.

--
Artem