• Eric Dumazet's avatar
    dccp: initialize ireq->ir_mark · 543cb05d
    Eric Dumazet authored
    commit b855ff82 upstream.
    
    syzbot reported an uninit-value read of skb->mark in iptable_mangle_hook()
    
    Thanks to the nice report, I tracked the problem to dccp not caring
    of ireq->ir_mark for passive sessions.
    
    BUG: KMSAN: uninit-value in ipt_mangle_out net/ipv4/netfilter/iptable_mangle.c:66 [inline]
    BUG: KMSAN: uninit-value in iptable_mangle_hook+0x5e5/0x720 net/ipv4/netfilter/iptable_mangle.c:84
    CPU: 0 PID: 5300 Comm: syz-executor3 Not tainted 4.16.0+ #81
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x185/0x1d0 lib/dump_stack.c:53
     kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
     __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676
     ipt_mangle_out net/ipv4/netfilter/iptable_mangle.c:66 [inline]
     iptable_mangle_hook+0x5e5/0x720 net/ipv4/netfilter/iptable_mangle.c:84
     nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
     nf_hook_slow+0x158/0x3d0 net/netfilter/core.c:483
     nf_hook include/linux/netfilter.h:243 [inline]
     __ip_local_out net/ipv4/ip_output.c:113 [inline]
     ip_local_out net/ipv4/ip_output.c:122 [inline]
     ip_queue_xmit+0x1d21/0x21c0 net/ipv4/ip_output.c:504
     dccp_transmit_skb+0x15eb/0x1900 net/dccp/output.c:142
     dccp_xmit_packet+0x814/0x9e0 net/dccp/output.c:281
     dccp_write_xmit+0x20f/0x480 net/dccp/output.c:363
     dccp_sendmsg+0x12ca/0x12d0 net/dccp/proto.c:818
     inet_sendmsg+0x48d/0x740 net/ipv4/af_inet.c:764
     sock_sendmsg_nosec net/socket.c:630 [inline]
     sock_sendmsg net/socket.c:640 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2046
     __sys_sendmsg net/socket.c:2080 [inline]
     SYSC_sendmsg+0x2a3/0x3d0 net/socket.c:2091
     SyS_sendmsg+0x54/0x80 net/socket.c:2087
     do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x455259
    RSP: 002b:00007f1a4473dc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00007f1a4473e6d4 RCX: 0000000000455259
    RDX: 0000000000000000 RSI: 0000000020b76fc8 RDI: 0000000000000015
    RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 00000000000004f0 R14: 00000000006fa720 R15: 0000000000000000
    
    Uninit was stored to memory at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:278 [inline]
     kmsan_save_stack mm/kmsan/kmsan.c:293 [inline]
     kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:684
     __msan_chain_origin+0x69/0xc0 mm/kmsan/kmsan_instr.c:521
     ip_queue_xmit+0x1e35/0x21c0 net/ipv4/ip_output.c:502
     dccp_transmit_skb+0x15eb/0x1900 net/dccp/output.c:142
     dccp_xmit_packet+0x814/0x9e0 net/dccp/output.c:281
     dccp_write_xmit+0x20f/0x480 net/dccp/output.c:363
     dccp_sendmsg+0x12ca/0x12d0 net/dccp/proto.c:818
     inet_sendmsg+0x48d/0x740 net/ipv4/af_inet.c:764
     sock_sendmsg_nosec net/socket.c:630 [inline]
     sock_sendmsg net/socket.c:640 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2046
     __sys_sendmsg net/socket.c:2080 [inline]
     SYSC_sendmsg+0x2a3/0x3d0 net/socket.c:2091
     SyS_sendmsg+0x54/0x80 net/socket.c:2087
     do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    Uninit was stored to memory at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:278 [inline]
     kmsan_save_stack mm/kmsan/kmsan.c:293 [inline]
     kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:684
     __msan_chain_origin+0x69/0xc0 mm/kmsan/kmsan_instr.c:521
     inet_csk_clone_lock+0x503/0x580 net/ipv4/inet_connection_sock.c:797
     dccp_create_openreq_child+0x7f/0x890 net/dccp/minisocks.c:92
     dccp_v4_request_recv_sock+0x22c/0xe90 net/dccp/ipv4.c:408
     dccp_v6_request_recv_sock+0x290/0x2000 net/dccp/ipv6.c:414
     dccp_check_req+0x7b9/0x8f0 net/dccp/minisocks.c:197
     dccp_v4_rcv+0x12e4/0x2630 net/dccp/ipv4.c:840
     ip_local_deliver_finish+0x6ed/0xd40 net/ipv4/ip_input.c:216
     NF_HOOK include/linux/netfilter.h:288 [inline]
     ip_local_deliver+0x43c/0x4e0 net/ipv4/ip_input.c:257
     dst_input include/net/dst.h:449 [inline]
     ip_rcv_finish+0x1253/0x16d0 net/ipv4/ip_input.c:397
     NF_HOOK include/linux/netfilter.h:288 [inline]
     ip_rcv+0x119d/0x16f0 net/ipv4/ip_input.c:493
     __netif_receive_skb_core+0x47cf/0x4a80 net/core/dev.c:4562
     __netif_receive_skb net/core/dev.c:4627 [inline]
     process_backlog+0x62d/0xe20 net/core/dev.c:5307
     napi_poll net/core/dev.c:5705 [inline]
     net_rx_action+0x7c1/0x1a70 net/core/dev.c:5771
     __do_softirq+0x56d/0x93d kernel/softirq.c:285
    Uninit was created at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:278 [inline]
     kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:188
     kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:314
     kmem_cache_alloc+0xaab/0xb90 mm/slub.c:2756
     reqsk_alloc include/net/request_sock.h:88 [inline]
     inet_reqsk_alloc+0xc4/0x7f0 net/ipv4/tcp_input.c:6145
     dccp_v4_conn_request+0x5cc/0x1770 net/dccp/ipv4.c:600
     dccp_v6_conn_request+0x299/0x1880 net/dccp/ipv6.c:317
     dccp_rcv_state_process+0x2ea/0x2410 net/dccp/input.c:612
     dccp_v4_do_rcv+0x229/0x340 net/dccp/ipv4.c:682
     dccp_v6_do_rcv+0x16d/0x1220 net/dccp/ipv6.c:578
     sk_backlog_rcv include/net/sock.h:908 [inline]
     __sk_receive_skb+0x60e/0xf20 net/core/sock.c:513
     dccp_v4_rcv+0x24d4/0x2630 net/dccp/ipv4.c:874
     ip_local_deliver_finish+0x6ed/0xd40 net/ipv4/ip_input.c:216
     NF_HOOK include/linux/netfilter.h:288 [inline]
     ip_local_deliver+0x43c/0x4e0 net/ipv4/ip_input.c:257
     dst_input include/net/dst.h:449 [inline]
     ip_rcv_finish+0x1253/0x16d0 net/ipv4/ip_input.c:397
     NF_HOOK include/linux/netfilter.h:288 [inline]
     ip_rcv+0x119d/0x16f0 net/ipv4/ip_input.c:493
     __netif_receive_skb_core+0x47cf/0x4a80 net/core/dev.c:4562
     __netif_receive_skb net/core/dev.c:4627 [inline]
     process_backlog+0x62d/0xe20 net/core/dev.c:5307
     napi_poll net/core/dev.c:5705 [inline]
     net_rx_action+0x7c1/0x1a70 net/core/dev.c:5771
     __do_softirq+0x56d/0x93d kernel/softirq.c:285
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    543cb05d
ipv6.c 29.7 KB