Re: UBSAN: Undefined behaviour in net/ipv4/fib_trie.c:1397:22 and UBSAN: Undefined behaviour in ./arch/x86/include/asm/atomic.h:156:2

From: Alexander Duyck
Date: Thu Jan 28 2016 - 12:15:16 EST


On Tue, Jan 26, 2016 at 1:36 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> On Tue, 2016-01-26 at 20:45 +0100, Toralf FÃrster wrote:
>> at a 32 nbit KVM image of a Gentoo Linux runniogn v4.5-rc1 - attached is /var/log/messages
>>
>
> Jan 26 20:40:04 n22kvm-clone kernel: ================================================================================
> Jan 26 20:40:04 n22kvm-clone kernel: UBSAN: Undefined behaviour in net/ipv4/fib_trie.c:1397:22
> Jan 26 20:40:04 n22kvm-clone kernel: shift exponent 32 is too large for 32-bit type 'long unsigned int'
> Jan 26 20:40:04 n22kvm-clone kernel: CPU: 1 PID: 2050 Comm: dhcpcd Not tainted 4.5.0-rc1 #1
> Jan 26 20:40:04 n22kvm-clone kernel: Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
>
> Thanks for the report.
>
> CC netdev and Alexander
>
> Commit 79e5ad2ceb006
> ("fib_trie: Remove leaf_info ")

I looked over the line in question, it is an issue where we are doing
the shift and then sanitizing for the undefined result after the fact.
I'll see about submitting a patch to address this.

- Alex