Re: [syzbot] KMSAN: uninit-value in hsr_fill_frame_info (2)

From: Eric Dumazet
Date: Wed Oct 12 2022 - 15:25:46 EST



On 10/12/22 12:10, syzbot wrote:
Hello,

syzbot found the following issue on:

HEAD commit: d6e2c8c7eb40 x86: kmsan: enable KMSAN builds for x86
git tree: https://github.com/google/kmsan.git master
console+strace: https://syzkaller.appspot.com/x/log.txt?x=143fe3c6f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=65d9eb7bfd2865c9
dashboard link: https://syzkaller.appspot.com/bug?extid=b11c500e990cac6ba129
compiler: clang version 14.0.0 (/usr/local/google/src/llvm-git-monorepo 2b554920f11c8b763cd9ed9003f4e19b919b8e1f), GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1257629ef00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17959c21f00000


Might be related to


commit 48b491a5cc74333c4a6a82fe21cea42c055a3b0b
Author: George McCollister <george.mccollister@xxxxxxxxx>
Date:   Mon May 24 13:50:54 2021 -0500

    net: hsr: fix mac_len checks

    Commit 2e9f60932a2c ("net: hsr: check skb can contain struct hsr_ethhdr
    in fill_frame_info") added the following which resulted in -EINVAL
    always being returned:
            if (skb->mac_len < sizeof(struct hsr_ethhdr))
                    return -EINVAL;

    mac_len was not being set correctly so this check completely broke
    HSR/PRP since it was always 14, not 20.

    Set mac_len correctly and modify the mac_len checks to test in the
    correct places since sometimes it is legitimately 14.

    Fixes: 2e9f60932a2c ("net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info")
    Signed-off-by: George McCollister <george.mccollister@xxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>


IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b11c500e990cac6ba129@xxxxxxxxxxxxxxxxxxxxxxxxx

hsr0: VLAN not yet supported
=====================================================
BUG: KMSAN: uninit-value in hsr_fill_frame_info+0x495/0x770 net/hsr/hsr_forward.c:526
hsr_fill_frame_info+0x495/0x770 net/hsr/hsr_forward.c:526
fill_frame_info net/hsr/hsr_forward.c:605 [inline]
hsr_forward_skb+0x7c4/0x3630 net/hsr/hsr_forward.c:619
hsr_dev_xmit+0x23a/0x530 net/hsr/hsr_device.c:222
__netdev_start_xmit include/linux/netdevice.h:4778 [inline]
netdev_start_xmit include/linux/netdevice.h:4792 [inline]
xmit_one+0x2f4/0x840 net/core/dev.c:3532
dev_hard_start_xmit+0x186/0x440 net/core/dev.c:3548
__dev_queue_xmit+0x22ee/0x3500 net/core/dev.c:4176
dev_queue_xmit+0x4b/0x60 net/core/dev.c:4209
packet_snd net/packet/af_packet.c:3063 [inline]
packet_sendmsg+0x6671/0x7d60 net/packet/af_packet.c:3094
sock_sendmsg_nosec net/socket.c:705 [inline]
sock_sendmsg net/socket.c:725 [inline]
__sys_sendto+0x9ef/0xc70 net/socket.c:2040
__do_sys_sendto net/socket.c:2052 [inline]
__se_sys_sendto net/socket.c:2048 [inline]
__x64_sys_sendto+0x19c/0x210 net/socket.c:2048
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x51/0xa0 arch/x86/entry/common.c:81
entry_SYSCALL_64_after_hwframe+0x44/0xae

Uninit was created at:
slab_post_alloc_hook mm/slab.h:754 [inline]
slab_alloc_node mm/slub.c:3231 [inline]
__kmalloc_node_track_caller+0xde3/0x14f0 mm/slub.c:4962
kmalloc_reserve net/core/skbuff.c:354 [inline]
__alloc_skb+0x545/0xf90 net/core/skbuff.c:426
alloc_skb include/linux/skbuff.h:1300 [inline]
alloc_skb_with_frags+0x1df/0xd60 net/core/skbuff.c:5995
sock_alloc_send_pskb+0xdf4/0xfc0 net/core/sock.c:2600
packet_alloc_skb net/packet/af_packet.c:2911 [inline]
packet_snd net/packet/af_packet.c:3006 [inline]
packet_sendmsg+0x506f/0x7d60 net/packet/af_packet.c:3094
sock_sendmsg_nosec net/socket.c:705 [inline]
sock_sendmsg net/socket.c:725 [inline]
__sys_sendto+0x9ef/0xc70 net/socket.c:2040
__do_sys_sendto net/socket.c:2052 [inline]
__se_sys_sendto net/socket.c:2048 [inline]
__x64_sys_sendto+0x19c/0x210 net/socket.c:2048
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x51/0xa0 arch/x86/entry/common.c:81
entry_SYSCALL_64_after_hwframe+0x44/0xae

CPU: 1 PID: 3506 Comm: syz-executor134 Not tainted 5.18.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
=====================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches