17 Jun, 2020

2 commits

  • [ Upstream commit 53fc685243bd6fb90d90305cea54598b78d3cbfc ]

    When neighbor suppression is enabled the bridge device might reply to
    Neighbor Solicitation (NS) messages on behalf of remote hosts.

    In case the NS message includes the "Source link-layer address" option
    [1], the bridge device will use the specified address as the link-layer
    destination address in its reply.

    To avoid an infinite loop, break out of the options parsing loop when
    encountering an option with length zero and disregard the NS message.

    This is consistent with the IPv6 ndisc code and RFC 4886 which states
    that "Nodes MUST silently discard an ND packet that contains an option
    with length zero" [2].

    [1] https://tools.ietf.org/html/rfc4861#section-4.3
    [2] https://tools.ietf.org/html/rfc4861#section-4.6

    Fixes: ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")
    Signed-off-by: Ido Schimmel
    Reported-by: Alla Segal
    Tested-by: Alla Segal
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Ido Schimmel
     
  • [ Upstream commit 79a1f0ccdbb4ad700590f61b00525b390cb53905 ]

    Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present.
    Previously the checking logic looks like:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    do_some_check;
    else if (sk->sk_protocol != IPPROTO_TCP)
    break;

    After commit b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP
    was blocked as the logic changed to:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    do_some_check;
    else if (sk->sk_protocol == IPPROTO_TCP)
    do_some_check;
    break;
    else
    break;

    Then after commit 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation")
    UDP/UDPLITE were blocked as the logic changed to:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    do_some_check;
    if (sk->sk_protocol == IPPROTO_TCP)
    do_some_check;

    if (sk->sk_protocol != IPPROTO_TCP)
    break;

    Fix it by using Eric's code and simply remove the break in TCP check, which
    looks like:
    if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
    do_some_check;
    else if (sk->sk_protocol == IPPROTO_TCP)
    do_some_check;
    else
    break;

    Fixes: 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation")
    Signed-off-by: Hangbin Liu
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     

11 Jun, 2020

4 commits

  • [ Upstream commit 7e0afbdfd13d1e708fe96e31c46c4897101a6a43 ]

    The accept(2) is an "input" socket interface, so we should use
    SO_RCVTIMEO instead of SO_SNDTIMEO to set the timeout.

    So this patch replace sock_sndtimeo() with sock_rcvtimeo() to
    use the right timeout in the vsock_accept().

    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Signed-off-by: Stefano Garzarella
    Reviewed-by: Jorgen Hansen
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Stefano Garzarella
     
  • [ Upstream commit 02c71b144c811bcdd865e0a1226d0407d11357e8 ]

    syzbot recently found a way to crash the kernel [1]

    Issue here is that inet_hash() & inet_unhash() are currently
    only meant to be used by TCP & DCCP, since only these protocols
    provide the needed hashinfo pointer.

    L2TP uses a single list (instead of a hash table)

    This old bug became an issue after commit 610236587600
    ("bpf: Add new cgroup attach type to enable sock modifications")
    since after this commit, sk_common_release() can be called
    while the L2TP socket is still considered 'hashed'.

    general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN
    KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
    CPU: 0 PID: 7063 Comm: syz-executor654 Not tainted 5.7.0-rc6-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    RIP: 0010:inet_unhash+0x11f/0x770 net/ipv4/inet_hashtables.c:600
    Code: 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e dd 04 00 00 48 8d 7d 08 44 8b 73 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 3c 02 00 0f 85 55 05 00 00 48 8d 7d 14 4c 8b 6d 08 48 b8 00 00
    RSP: 0018:ffffc90001777d30 EFLAGS: 00010202
    RAX: dffffc0000000000 RBX: ffff88809a6df940 RCX: ffffffff8697c242
    RDX: 0000000000000001 RSI: ffffffff8697c251 RDI: 0000000000000008
    RBP: 0000000000000000 R08: ffff88809f3ae1c0 R09: fffffbfff1514cc1
    R10: ffffffff8a8a6607 R11: fffffbfff1514cc0 R12: ffff88809a6df9b0
    R13: 0000000000000007 R14: 0000000000000000 R15: ffffffff873a4d00
    FS: 0000000001d2b880(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000006cd090 CR3: 000000009403a000 CR4: 00000000001406f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    sk_common_release+0xba/0x370 net/core/sock.c:3210
    inet_create net/ipv4/af_inet.c:390 [inline]
    inet_create+0x966/0xe00 net/ipv4/af_inet.c:248
    __sock_create+0x3cb/0x730 net/socket.c:1428
    sock_create net/socket.c:1479 [inline]
    __sys_socket+0xef/0x200 net/socket.c:1521
    __do_sys_socket net/socket.c:1530 [inline]
    __se_sys_socket net/socket.c:1528 [inline]
    __x64_sys_socket+0x6f/0xb0 net/socket.c:1528
    do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
    entry_SYSCALL_64_after_hwframe+0x49/0xb3
    RIP: 0033:0x441e29
    Code: e8 fc b3 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 0f 83 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007ffdce184148 EFLAGS: 00000246 ORIG_RAX: 0000000000000029
    RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000441e29
    RDX: 0000000000000073 RSI: 0000000000000002 RDI: 0000000000000002
    RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
    R13: 0000000000402c30 R14: 0000000000000000 R15: 0000000000000000
    Modules linked in:
    ---[ end trace 23b6578228ce553e ]---
    RIP: 0010:inet_unhash+0x11f/0x770 net/ipv4/inet_hashtables.c:600
    Code: 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e dd 04 00 00 48 8d 7d 08 44 8b 73 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 3c 02 00 0f 85 55 05 00 00 48 8d 7d 14 4c 8b 6d 08 48 b8 00 00
    RSP: 0018:ffffc90001777d30 EFLAGS: 00010202
    RAX: dffffc0000000000 RBX: ffff88809a6df940 RCX: ffffffff8697c242
    RDX: 0000000000000001 RSI: ffffffff8697c251 RDI: 0000000000000008
    RBP: 0000000000000000 R08: ffff88809f3ae1c0 R09: fffffbfff1514cc1
    R10: ffffffff8a8a6607 R11: fffffbfff1514cc0 R12: ffff88809a6df9b0
    R13: 0000000000000007 R14: 0000000000000000 R15: ffffffff873a4d00
    FS: 0000000001d2b880(0000) GS:ffff8880ae600000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000006cd090 CR3: 000000009403a000 CR4: 00000000001406f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

    Fixes: 0d76751fad77 ("l2tp: Add L2TPv3 IP encapsulation (no UDP) support")
    Signed-off-by: Eric Dumazet
    Cc: James Chapman
    Cc: Andrii Nakryiko
    Reported-by: syzbot+3610d489778b57cc8031@syzkaller.appspotmail.com
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit d9a81a225277686eb629938986d97629ea102633 ]

    syzbot was able to trigger a crash after using an ISDN socket
    and fool l2tp.

    Fix this by making sure the UDP socket is of the proper family.

    BUG: KASAN: slab-out-of-bounds in setup_udp_tunnel_sock+0x465/0x540 net/ipv4/udp_tunnel.c:78
    Write of size 1 at addr ffff88808ed0c590 by task syz-executor.5/3018

    CPU: 0 PID: 3018 Comm: syz-executor.5 Not tainted 5.7.0-rc6-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x188/0x20d lib/dump_stack.c:118
    print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:382
    __kasan_report.cold+0x20/0x38 mm/kasan/report.c:511
    kasan_report+0x33/0x50 mm/kasan/common.c:625
    setup_udp_tunnel_sock+0x465/0x540 net/ipv4/udp_tunnel.c:78
    l2tp_tunnel_register+0xb15/0xdd0 net/l2tp/l2tp_core.c:1523
    l2tp_nl_cmd_tunnel_create+0x4b2/0xa60 net/l2tp/l2tp_netlink.c:249
    genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
    genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
    genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
    netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
    genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
    netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
    netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
    netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
    sock_sendmsg_nosec net/socket.c:652 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:672
    ____sys_sendmsg+0x6e6/0x810 net/socket.c:2352
    ___sys_sendmsg+0x100/0x170 net/socket.c:2406
    __sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
    do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
    entry_SYSCALL_64_after_hwframe+0x49/0xb3
    RIP: 0033:0x45ca29
    Code: 0d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 0f 83 db b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007effe76edc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00000000004fe1c0 RCX: 000000000045ca29
    RDX: 0000000000000000 RSI: 0000000020000240 RDI: 0000000000000005
    RBP: 000000000078bf00 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 000000000000094e R14: 00000000004d5d00 R15: 00007effe76ee6d4

    Allocated by task 3018:
    save_stack+0x1b/0x40 mm/kasan/common.c:49
    set_track mm/kasan/common.c:57 [inline]
    __kasan_kmalloc mm/kasan/common.c:495 [inline]
    __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
    __do_kmalloc mm/slab.c:3656 [inline]
    __kmalloc+0x161/0x7a0 mm/slab.c:3665
    kmalloc include/linux/slab.h:560 [inline]
    sk_prot_alloc+0x223/0x2f0 net/core/sock.c:1612
    sk_alloc+0x36/0x1100 net/core/sock.c:1666
    data_sock_create drivers/isdn/mISDN/socket.c:600 [inline]
    mISDN_sock_create+0x272/0x400 drivers/isdn/mISDN/socket.c:796
    __sock_create+0x3cb/0x730 net/socket.c:1428
    sock_create net/socket.c:1479 [inline]
    __sys_socket+0xef/0x200 net/socket.c:1521
    __do_sys_socket net/socket.c:1530 [inline]
    __se_sys_socket net/socket.c:1528 [inline]
    __x64_sys_socket+0x6f/0xb0 net/socket.c:1528
    do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
    entry_SYSCALL_64_after_hwframe+0x49/0xb3

    Freed by task 2484:
    save_stack+0x1b/0x40 mm/kasan/common.c:49
    set_track mm/kasan/common.c:57 [inline]
    kasan_set_free_info mm/kasan/common.c:317 [inline]
    __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:456
    __cache_free mm/slab.c:3426 [inline]
    kfree+0x109/0x2b0 mm/slab.c:3757
    kvfree+0x42/0x50 mm/util.c:603
    __free_fdtable+0x2d/0x70 fs/file.c:31
    put_files_struct fs/file.c:420 [inline]
    put_files_struct+0x248/0x2e0 fs/file.c:413
    exit_files+0x7e/0xa0 fs/file.c:445
    do_exit+0xb04/0x2dd0 kernel/exit.c:791
    do_group_exit+0x125/0x340 kernel/exit.c:894
    get_signal+0x47b/0x24e0 kernel/signal.c:2739
    do_signal+0x81/0x2240 arch/x86/kernel/signal.c:784
    exit_to_usermode_loop+0x26c/0x360 arch/x86/entry/common.c:161
    prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
    syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
    do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305
    entry_SYSCALL_64_after_hwframe+0x49/0xb3

    The buggy address belongs to the object at ffff88808ed0c000
    which belongs to the cache kmalloc-2k of size 2048
    The buggy address is located 1424 bytes inside of
    2048-byte region [ffff88808ed0c000, ffff88808ed0c800)
    The buggy address belongs to the page:
    page:ffffea00023b4300 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
    flags: 0xfffe0000000200(slab)
    raw: 00fffe0000000200 ffffea0002838208 ffffea00015ba288 ffff8880aa000e00
    raw: 0000000000000000 ffff88808ed0c000 0000000100000001 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
    ffff88808ed0c480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ffff88808ed0c500: 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc
    >ffff88808ed0c580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    ^
    ffff88808ed0c600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    ffff88808ed0c680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

    Fixes: 6b9f34239b00 ("l2tp: fix races in tunnel creation")
    Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
    Signed-off-by: Eric Dumazet
    Cc: James Chapman
    Cc: Guillaume Nault
    Reported-by: syzbot
    Acked-by: Guillaume Nault
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit 1b49cd71b52403822731dc9f283185d1da355f97 ]

    When devinet_sysctl_register() failed, the memory allocated
    in neigh_parms_alloc() should be freed.

    Fixes: 20e61da7ffcf ("ipv4: fail early when creating netdev named all or default")
    Signed-off-by: Yang Yingliang
    Acked-by: Cong Wang
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Yang Yingliang
     

03 Jun, 2020

34 commits

  • commit 4946ea5c1237036155c3b3a24f049fd5f849f8f6 upstream.

    >> include/linux/netfilter/nf_conntrack_pptp.h:13:20: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
    extern const char *const pptp_msg_name(u_int16_t msg);
    ^~~~~~

    Reported-by: kbuild test robot
    Fixes: 4c559f15efcc ("netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code")
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit 46c1e0621a72e0469ec4edfdb6ed4d387ec34f8a upstream.

    Clang warns:

    net/netfilter/nf_conntrack_core.c:2068:21: warning: variable 'ctinfo' is
    uninitialized when used here [-Wuninitialized]
    nf_ct_set(skb, ct, ctinfo);
    ^~~~~~
    net/netfilter/nf_conntrack_core.c:2024:2: note: variable 'ctinfo' is
    declared here
    enum ip_conntrack_info ctinfo;
    ^
    1 warning generated.

    nf_conntrack_update was split up into nf_conntrack_update and
    __nf_conntrack_update, where the assignment of ctinfo is in
    nf_conntrack_update but it is used in __nf_conntrack_update.

    Pass the value of ctinfo from nf_conntrack_update to
    __nf_conntrack_update so that uninitialized memory is not used
    and everything works properly.

    Fixes: ee04805ff54a ("netfilter: conntrack: make conntrack userspace helpers work again")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1039
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Nathan Chancellor
     
  • commit 94945ad2b330207cded0fd8d4abebde43a776dfb upstream.

    net/netfilter/nf_conntrack_core.c: In function nf_confirm_cthelper:
    net/netfilter/nf_conntrack_core.c:2117:15: warning: comparison of unsigned expression in < 0 is always false [-Wtype-limits]
    2117 | if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
    | ^

    ipv6_skip_exthdr() returns a signed integer.

    Reported-by: Colin Ian King
    Fixes: 703acd70f249 ("netfilter: nfnetlink_cthelper: unbreak userspace helper support")
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit 2b86cb8299765688c5119fd18d5f436716c81010 upstream.

    Be there a platform with the following layout:

    Regular NIC
    |
    +----> DSA master for switch port
    |
    +----> DSA master for another switch port

    After changing DSA back to static lockdep class keys in commit
    1a33e10e4a95 ("net: partially revert dynamic lockdep key changes"), this
    kernel splat can be seen:

    [ 13.361198] ============================================
    [ 13.366524] WARNING: possible recursive locking detected
    [ 13.371851] 5.7.0-rc4-02121-gc32a05ecd7af-dirty #988 Not tainted
    [ 13.377874] --------------------------------------------
    [ 13.383201] swapper/0/0 is trying to acquire lock:
    [ 13.388004] ffff0000668ff298 (&dsa_slave_netdev_xmit_lock_key){+.-.}-{2:2}, at: __dev_queue_xmit+0x84c/0xbe0
    [ 13.397879]
    [ 13.397879] but task is already holding lock:
    [ 13.403727] ffff0000661a1698 (&dsa_slave_netdev_xmit_lock_key){+.-.}-{2:2}, at: __dev_queue_xmit+0x84c/0xbe0
    [ 13.413593]
    [ 13.413593] other info that might help us debug this:
    [ 13.420140] Possible unsafe locking scenario:
    [ 13.420140]
    [ 13.426075] CPU0
    [ 13.428523] ----
    [ 13.430969] lock(&dsa_slave_netdev_xmit_lock_key);
    [ 13.435946] lock(&dsa_slave_netdev_xmit_lock_key);
    [ 13.440924]
    [ 13.440924] *** DEADLOCK ***
    [ 13.440924]
    [ 13.446860] May be due to missing lock nesting notation
    [ 13.446860]
    [ 13.453668] 6 locks held by swapper/0/0:
    [ 13.457598] #0: ffff800010003de0 ((&idev->mc_ifc_timer)){+.-.}-{0:0}, at: call_timer_fn+0x0/0x400
    [ 13.466593] #1: ffffd4d3fb478700 (rcu_read_lock){....}-{1:2}, at: mld_sendpack+0x0/0x560
    [ 13.474803] #2: ffffd4d3fb478728 (rcu_read_lock_bh){....}-{1:2}, at: ip6_finish_output2+0x64/0xb10
    [ 13.483886] #3: ffffd4d3fb478728 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0x6c/0xbe0
    [ 13.492793] #4: ffff0000661a1698 (&dsa_slave_netdev_xmit_lock_key){+.-.}-{2:2}, at: __dev_queue_xmit+0x84c/0xbe0
    [ 13.503094] #5: ffffd4d3fb478728 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0x6c/0xbe0
    [ 13.512000]
    [ 13.512000] stack backtrace:
    [ 13.516369] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-rc4-02121-gc32a05ecd7af-dirty #988
    [ 13.530421] Call trace:
    [ 13.532871] dump_backtrace+0x0/0x1d8
    [ 13.536539] show_stack+0x24/0x30
    [ 13.539862] dump_stack+0xe8/0x150
    [ 13.543271] __lock_acquire+0x1030/0x1678
    [ 13.547290] lock_acquire+0xf8/0x458
    [ 13.550873] _raw_spin_lock+0x44/0x58
    [ 13.554543] __dev_queue_xmit+0x84c/0xbe0
    [ 13.558562] dev_queue_xmit+0x24/0x30
    [ 13.562232] dsa_slave_xmit+0xe0/0x128
    [ 13.565988] dev_hard_start_xmit+0xf4/0x448
    [ 13.570182] __dev_queue_xmit+0x808/0xbe0
    [ 13.574200] dev_queue_xmit+0x24/0x30
    [ 13.577869] neigh_resolve_output+0x15c/0x220
    [ 13.582237] ip6_finish_output2+0x244/0xb10
    [ 13.586430] __ip6_finish_output+0x1dc/0x298
    [ 13.590709] ip6_output+0x84/0x358
    [ 13.594116] mld_sendpack+0x2bc/0x560
    [ 13.597786] mld_ifc_timer_expire+0x210/0x390
    [ 13.602153] call_timer_fn+0xcc/0x400
    [ 13.605822] run_timer_softirq+0x588/0x6e0
    [ 13.609927] __do_softirq+0x118/0x590
    [ 13.613597] irq_exit+0x13c/0x148
    [ 13.616918] __handle_domain_irq+0x6c/0xc0
    [ 13.621023] gic_handle_irq+0x6c/0x160
    [ 13.624779] el1_irq+0xbc/0x180
    [ 13.627927] cpuidle_enter_state+0xb4/0x4d0
    [ 13.632120] cpuidle_enter+0x3c/0x50
    [ 13.635703] call_cpuidle+0x44/0x78
    [ 13.639199] do_idle+0x228/0x2c8
    [ 13.642433] cpu_startup_entry+0x2c/0x48
    [ 13.646363] rest_init+0x1ac/0x280
    [ 13.649773] arch_call_rest_init+0x14/0x1c
    [ 13.653878] start_kernel+0x490/0x4bc

    Lockdep keys themselves were added in commit ab92d68fc22f ("net: core:
    add generic lockdep keys"), and it's very likely that this splat existed
    since then, but I have no real way to check, since this stacked platform
    wasn't supported by mainline back then.

    >From Taehee's own words:

    This patch was considered that all stackable devices have LLTX flag.
    But the dsa doesn't have LLTX, so this splat happened.
    After this patch, dsa shares the same lockdep class key.
    On the nested dsa interface architecture, which you illustrated,
    the same lockdep class key will be used in __dev_queue_xmit() because
    dsa doesn't have LLTX.
    So that lockdep detects deadlock because the same lockdep class key is
    used recursively although actually the different locks are used.
    There are some ways to fix this problem.

    1. using NETIF_F_LLTX flag.
    If possible, using the LLTX flag is a very clear way for it.
    But I'm so sorry I don't know whether the dsa could have LLTX or not.

    2. using dynamic lockdep again.
    It means that each interface uses a separate lockdep class key.
    So, lockdep will not detect recursive locking.
    But this way has a problem that it could consume lockdep class key
    too many.
    Currently, lockdep can have 8192 lockdep class keys.
    - you can see this number with the following command.
    cat /proc/lockdep_stats
    lock-classes: 1251 [max: 8192]
    ...
    The [max: 8192] means that the maximum number of lockdep class keys.
    If too many lockdep class keys are registered, lockdep stops to work.
    So, using a dynamic(separated) lockdep class key should be considered
    carefully.
    In addition, updating lockdep class key routine might have to be existing.
    (lockdep_register_key(), lockdep_set_class(), lockdep_unregister_key())

    3. Using lockdep subclass.
    A lockdep class key could have 8 subclasses.
    The different subclass is considered different locks by lockdep
    infrastructure.
    But "lock-classes" is not counted by subclasses.
    So, it could avoid stopping lockdep infrastructure by an overflow of
    lockdep class keys.
    This approach should also have an updating lockdep class key routine.
    (lockdep_set_subclass())

    4. Using nonvalidate lockdep class key.
    The lockdep infrastructure supports nonvalidate lockdep class key type.
    It means this lockdep is not validated by lockdep infrastructure.
    So, the splat will not happen but lockdep couldn't detect real deadlock
    case because lockdep really doesn't validate it.
    I think this should be used for really special cases.
    (lockdep_set_novalidate_class())

    Further discussion here:
    https://patchwork.ozlabs.org/project/netdev/patch/20200503052220.4536-2-xiyou.wangcong@gmail.com/

    There appears to be no negative side-effect to declaring lockless TX for
    the DSA virtual interfaces, which means they handle their own locking.
    So that's what we do to make the splat go away.

    Patch tested in a wide variety of cases: unicast, multicast, PTP, etc.

    Fixes: ab92d68fc22f ("net: core: add generic lockdep keys")
    Suggested-by: Taehee Yoo
    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Vladimir Oltean
     
  • commit 1fd1c768f3624a5e66766e7b4ddb9b607cd834a5 upstream.

    Similar to the last path, need to fix fib_info_nh_uses_dev for
    external nexthops to avoid referencing multiple nh_grp structs.
    Move the device check in fib_info_nh_uses_dev to a helper and
    create a nexthop version that is called if the fib_info uses an
    external nexthop.

    Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
    Signed-off-by: David Ahern
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    David Ahern
     
  • commit 90f33bffa382598a32cc82abfeb20adc92d041b6 upstream.

    We must avoid modifying published nexthop groups while they might be
    in use, otherwise we might see NULL ptr dereferences. In order to do
    that we allocate 2 nexthoup group structures upon nexthop creation
    and swap between them when we have to delete an entry. The reason is
    that we can't fail nexthop group removal, so we can't handle allocation
    failure thus we move the extra allocation on creation where we can
    safely fail and return ENOMEM.

    Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Nikolay Aleksandrov
     
  • commit ac21753a5c2c9a6a2019997481a2ac12bbde48c8 upstream.

    Move nh_grp dereference and check for removing nexthop group due to
    all members gone into remove_nh_grp_entry.

    Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
    Signed-off-by: David Ahern
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    David Ahern
     
  • commit b16a87d0aef7a6be766f6618976dc5ff2c689291 upstream.

    The npgs member of struct xdp_umem is an u32 entity, and stores the
    number of pages the UMEM consumes. The calculation of npgs

    npgs = size / PAGE_SIZE

    can overflow.

    To avoid overflow scenarios, the division is now first stored in a
    u64, and the result is verified to fit into 32b.

    An alternative would be storing the npgs as a u64, however, this
    wastes memory and is an unrealisticly large packet area.

    Fixes: c0c77d8fb787 ("xsk: add user memory registration support sockopt")
    Reported-by: "Minh Bùi Quang"
    Signed-off-by: Björn Töpel
    Signed-off-by: Daniel Borkmann
    Acked-by: Jonathan Lemon
    Link: https://lore.kernel.org/bpf/CACtPs=GGvV-_Yj6rbpzTVnopgi5nhMoCcTkSkYrJHGQHJWFZMQ@mail.gmail.com/
    Link: https://lore.kernel.org/bpf/20200525080400.13195-1-bjorn.topel@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Björn Töpel
     
  • commit 3c96ec56828922e3fe5477f75eb3fc02f98f98b5 upstream.

    For transport mode, when ipv6 nexthdr is set, the packet format might
    be like:

    ----------------------------------------------------
    | | dest | | | | ESP | ESP |
    | IP6 hdr| opts.| ESP | TCP | Data | Trailer | ICV |
    ----------------------------------------------------

    What it wants to get for x-proto in esp6_gso_encap() is the proto that
    will be set in ESP nexthdr. So it should skip all ipv6 nexthdrs and
    get the real transport protocol. Othersize, the wrong proto number
    will be set into ESP nexthdr.

    This patch is to skip all ipv6 nexthdrs by calling ipv6_skip_exthdr()
    in esp6_gso_encap().

    Fixes: 7862b4058b9f ("esp: Add gso handlers for esp4 and esp6")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit 4c559f15efcc43b996f4da528cd7f9483aaca36d upstream.

    Dan Carpenter says: "Smatch complains that the value for "cmd" comes
    from the network and can't be trusted."

    Add pptp_msg_name() helper function that checks for the array boundary.

    Fixes: f09943fefe6b ("[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port")
    Reported-by: Dan Carpenter
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit 703acd70f2496537457186211c2f03e792409e68 upstream.

    Restore helper data size initialization and fix memcopy of the helper
    data size.

    Fixes: 157ffffeb5dc ("netfilter: nfnetlink_cthelper: reject too large userspace allocation requests")
    Reviewed-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit ee04805ff54a63ffd90bc6749ebfe73473734ddb upstream.

    Florian Westphal says:

    "Problem is that after the helper hook was merged back into the confirm
    one, the queueing itself occurs from the confirm hook, i.e. we queue
    from the last netfilter callback in the hook-list.

    Therefore, on return, the packet bypasses the confirm action and the
    connection is never committed to the main conntrack table.

    To fix this there are several ways:
    1. revert the 'Fixes' commit and have a extra helper hook again.
    Works, but has the drawback of adding another indirect call for
    everyone.

    2. Special case this: split the hooks only when userspace helper
    gets added, so queueing occurs at a lower priority again,
    and normal enqueue reinject would eventually call the last hook.

    3. Extend the existing nf_queue ct update hook to allow a forced
    confirmation (plus run the seqadj code).

    This goes for 3)."

    Fixes: 827318feb69cb ("netfilter: conntrack: remove helper hook again")
    Reviewed-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit a164b95ad6055c50612795882f35e0efda1f1390 upstream.

    If IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE is set, user requested to not
    update counters in sub sets. Therefore IPSET_FLAG_SKIP_COUNTER_UPDATE
    must be set, not unset.

    Fixes: 6e01781d1c80e ("netfilter: ipset: set match: add support to match the counters")
    Signed-off-by: Phil Sutter
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Phil Sutter
     
  • commit e9c284ec4b41c827f4369973d2792992849e4fa5 upstream.

    Currently, using the bridge reject target with tagged packets
    results in untagged packets being sent back.

    Fix this by mirroring the vlan id as well.

    Fixes: 85f5b3086a04 ("netfilter: bridge: add reject support")
    Signed-off-by: Michael Braun
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Michael Braun
     
  • commit 976eba8ab596bab94b9714cd46d38d5c6a2c660d upstream.

    In Commit dd9ee3444014 ("vti4: Fix a ipip packet processing bug in
    'IPCOMP' virtual tunnel"), it tries to receive IPIP packets in vti
    by calling xfrm_input(). This case happens when a small packet or
    frag sent by peer is too small to get compressed.

    However, xfrm_input() will still get to the IPCOMP path where skb
    sec_path is set, but never dropped while it should have been done
    in vti_ipcomp4_protocol.cb_handler(vti_rcv_cb), as it's not an
    ipcomp4 packet. This will cause that the packet can never pass
    xfrm4_policy_check() in the upper protocol rcv functions.

    So this patch is to call ip_tunnel_rcv() to process IPIP packets
    instead.

    Fixes: dd9ee3444014 ("vti4: Fix a ipip packet processing bug in 'IPCOMP' virtual tunnel")
    Reported-by: Xiumei Mu
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit f6a23d85d078c2ffde79c66ca81d0a1dde451649 upstream.

    This patch is to fix a crash:

    [ ] kasan: GPF could be caused by NULL-ptr deref or user memory access
    [ ] general protection fault: 0000 [#1] SMP KASAN PTI
    [ ] RIP: 0010:ipv6_local_error+0xac/0x7a0
    [ ] Call Trace:
    [ ] xfrm6_local_error+0x1eb/0x300
    [ ] xfrm_local_error+0x95/0x130
    [ ] __xfrm6_output+0x65f/0xb50
    [ ] xfrm6_output+0x106/0x46f
    [ ] udp_tunnel6_xmit_skb+0x618/0xbf0 [ip6_udp_tunnel]
    [ ] vxlan_xmit_one+0xbc6/0x2c60 [vxlan]
    [ ] vxlan_xmit+0x6a0/0x4276 [vxlan]
    [ ] dev_hard_start_xmit+0x165/0x820
    [ ] __dev_queue_xmit+0x1ff0/0x2b90
    [ ] ip_finish_output2+0xd3e/0x1480
    [ ] ip_do_fragment+0x182d/0x2210
    [ ] ip_output+0x1d0/0x510
    [ ] ip_send_skb+0x37/0xa0
    [ ] raw_sendmsg+0x1b4c/0x2b80
    [ ] sock_sendmsg+0xc0/0x110

    This occurred when sending a v4 skb over vxlan6 over ipsec, in which case
    skb->protocol == htons(ETH_P_IPV6) while skb->sk->sk_family == AF_INET in
    xfrm_local_error(). Then it will go to xfrm6_local_error() where it tries
    to get ipv6 info from a ipv4 sk.

    This issue was actually fixed by Commit 628e341f319f ("xfrm: make local
    error reporting more robust"), but brought back by Commit 844d48746e4b
    ("xfrm: choose protocol family by skb protocol").

    So to fix it, we should call xfrm6_local_error() only when skb->protocol
    is htons(ETH_P_IPV6) and skb->sk->sk_family is AF_INET6.

    Fixes: 844d48746e4b ("xfrm: choose protocol family by skb protocol")
    Reported-by: Xiumei Mu
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit ed17b8d377eaf6b4a01d46942b4c647378a79bdd upstream.

    This waring can be triggered simply by:

    # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
    priority 1 mark 0 mask 0x10 #[1]
    # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
    priority 2 mark 0 mask 0x1 #[2]
    # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
    priority 2 mark 0 mask 0x10 #[3]

    Then dmesg shows:

    [ ] WARNING: CPU: 1 PID: 7265 at net/xfrm/xfrm_policy.c:1548
    [ ] RIP: 0010:xfrm_policy_insert_list+0x2f2/0x1030
    [ ] Call Trace:
    [ ] xfrm_policy_inexact_insert+0x85/0xe50
    [ ] xfrm_policy_insert+0x4ba/0x680
    [ ] xfrm_add_policy+0x246/0x4d0
    [ ] xfrm_user_rcv_msg+0x331/0x5c0
    [ ] netlink_rcv_skb+0x121/0x350
    [ ] xfrm_netlink_rcv+0x66/0x80
    [ ] netlink_unicast+0x439/0x630
    [ ] netlink_sendmsg+0x714/0xbf0
    [ ] sock_sendmsg+0xe2/0x110

    The issue was introduced by Commit 7cb8a93968e3 ("xfrm: Allow inserting
    policies with matching mark and different priorities"). After that, the
    policies [1] and [2] would be able to be added with different priorities.

    However, policy [3] will actually match both [1] and [2]. Policy [1]
    was matched due to the 1st 'return true' in xfrm_policy_mark_match(),
    and policy [2] was matched due to the 2nd 'return true' in there. It
    caused WARN_ON() in xfrm_policy_insert_list().

    This patch is to fix it by only (the same value and priority) as the
    same policy in xfrm_policy_mark_match().

    Thanks to Yuehaibing, we could make this fix better.

    v1->v2:
    - check policy->mark.v == pol->mark.v only without mask.

    Fixes: 7cb8a93968e3 ("xfrm: Allow inserting policies with matching mark and different priorities")
    Reported-by: Xiumei Mu
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit c95c5f58b35ef995f66cb55547eee6093ab5fcb8 upstream.

    Here is the steps to reproduce the problem:
    ip netns add foo
    ip netns add bar
    ip -n foo link add xfrmi0 type xfrm dev lo if_id 42
    ip -n foo link set xfrmi0 netns bar
    ip netns del foo
    ip netns del bar

    Which results to:
    [ 186.686395] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6bd3: 0000 [#1] SMP PTI
    [ 186.687665] CPU: 7 PID: 232 Comm: kworker/u16:2 Not tainted 5.6.0+ #1
    [ 186.688430] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
    [ 186.689420] Workqueue: netns cleanup_net
    [ 186.689903] RIP: 0010:xfrmi_dev_uninit+0x1b/0x4b [xfrm_interface]
    [ 186.690657] Code: 44 f6 ff ff 31 c0 5b 5d 41 5c 41 5d 41 5e c3 48 8d 8f c0 08 00 00 8b 05 ce 14 00 00 48 8b 97 d0 08 00 00 48 8b 92 c0 0e 00 00 8b 14 c2 48 8b 02 48 85 c0 74 19 48 39 c1 75 0c 48 8b 87 c0 08
    [ 186.692838] RSP: 0018:ffffc900003b7d68 EFLAGS: 00010286
    [ 186.693435] RAX: 000000000000000d RBX: ffff8881b0f31000 RCX: ffff8881b0f318c0
    [ 186.694334] RDX: 6b6b6b6b6b6b6b6b RSI: 0000000000000246 RDI: ffff8881b0f31000
    [ 186.695190] RBP: ffffc900003b7df0 R08: ffff888236c07740 R09: 0000000000000040
    [ 186.696024] R10: ffffffff81fce1b8 R11: 0000000000000002 R12: ffffc900003b7d80
    [ 186.696859] R13: ffff8881edcc6a40 R14: ffff8881a1b6e780 R15: ffffffff81ed47c8
    [ 186.697738] FS: 0000000000000000(0000) GS:ffff888237dc0000(0000) knlGS:0000000000000000
    [ 186.698705] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 186.699408] CR2: 00007f2129e93148 CR3: 0000000001e0a000 CR4: 00000000000006e0
    [ 186.700221] Call Trace:
    [ 186.700508] rollback_registered_many+0x32b/0x3fd
    [ 186.701058] ? __rtnl_unlock+0x20/0x3d
    [ 186.701494] ? arch_local_irq_save+0x11/0x17
    [ 186.702012] unregister_netdevice_many+0x12/0x55
    [ 186.702594] default_device_exit_batch+0x12b/0x150
    [ 186.703160] ? prepare_to_wait_exclusive+0x60/0x60
    [ 186.703719] cleanup_net+0x17d/0x234
    [ 186.704138] process_one_work+0x196/0x2e8
    [ 186.704652] worker_thread+0x1a4/0x249
    [ 186.705087] ? cancel_delayed_work+0x92/0x92
    [ 186.705620] kthread+0x105/0x10f
    [ 186.706000] ? __kthread_bind_mask+0x57/0x57
    [ 186.706501] ret_from_fork+0x35/0x40
    [ 186.706978] Modules linked in: xfrm_interface nfsv3 nfs_acl auth_rpcgss nfsv4 nfs lockd grace fscache sunrpc button parport_pc parport serio_raw evdev pcspkr loop ext4 crc16 mbcache jbd2 crc32c_generic 8139too ide_cd_mod cdrom ide_gd_mod ata_generic ata_piix libata scsi_mod piix psmouse i2c_piix4 ide_core 8139cp i2c_core mii floppy
    [ 186.710423] ---[ end trace 463bba18105537e5 ]---

    The problem is that x-netns xfrm interface are not removed when the link
    netns is removed. This causes later this oops when thoses interfaces are
    removed.

    Let's add a handler to remove all interfaces related to a netns when this
    netns is removed.

    Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
    Reported-by: Christophe Gouault
    Signed-off-by: Nicolas Dichtel
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Nicolas Dichtel
     
  • commit a204aef9fd77dce1efd9066ca4e44eede99cd858 upstream.

    An use-after-free crash can be triggered when sending big packets over
    vxlan over esp with esp offload enabled:

    [] BUG: KASAN: use-after-free in ipv6_gso_pull_exthdrs.part.8+0x32c/0x4e0
    [] Call Trace:
    [] dump_stack+0x75/0xa0
    [] kasan_report+0x37/0x50
    [] ipv6_gso_pull_exthdrs.part.8+0x32c/0x4e0
    [] ipv6_gso_segment+0x2c8/0x13c0
    [] skb_mac_gso_segment+0x1cb/0x420
    [] skb_udp_tunnel_segment+0x6b5/0x1c90
    [] inet_gso_segment+0x440/0x1380
    [] skb_mac_gso_segment+0x1cb/0x420
    [] esp4_gso_segment+0xae8/0x1709 [esp4_offload]
    [] inet_gso_segment+0x440/0x1380
    [] skb_mac_gso_segment+0x1cb/0x420
    [] __skb_gso_segment+0x2d7/0x5f0
    [] validate_xmit_skb+0x527/0xb10
    [] __dev_queue_xmit+0x10f8/0x2320 inner_network_header would be
    set on vxlan_xmit() and xfrm4_tunnel_encap_add(), and the later one can
    overwrite the former one. It causes skb_udp_tunnel_segment() to use a
    wrong skb->inner_network_header, then the issue occurs.

    This patch is to fix it by calling xfrm_output_gso() instead when the
    inner_protocol is set, in which gso_segment of inner_protocol will be
    done first.

    While at it, also improve some code around.

    Fixes: 7862b4058b9f ("esp: Add gso handlers for esp4 and esp6")
    Reported-by: Xiumei Mu
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit db87668ad1e4917cfe04e217307ba6ed9390716e upstream.

    This xfrm_state_put call in esp4/6_gro_receive() will cause
    double put for state, as in out_reset path secpath_reset()
    will put all states set in skb sec_path.

    So fix it by simply remove the xfrm_state_put call.

    Fixes: 6ed69184ed9c ("xfrm: Reset secpath in xfrm failure")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit 06a0afcfe2f551ff755849ea2549b0d8409fd9a0 upstream.

    For transport mode, when ipv6 nexthdr is set, the packet format might
    be like:

    ----------------------------------------------------
    | | dest | | | | ESP | ESP |
    | IP6 hdr| opts.| ESP | TCP | Data | Trailer | ICV |
    ----------------------------------------------------

    and in __xfrm_transport_prep():

    pskb_pull(skb, skb->mac_len + sizeof(ip6hdr) + x->props.header_len);

    it will pull the data pointer to the wrong position, as it missed the
    nexthdrs/dest opts.

    This patch is to fix it by using:

    pskb_pull(skb, skb_transport_offset(skb) + x->props.header_len);

    as we can be sure transport_header points to ESP header at that moment.

    It also fixes a panic when packets with ipv6 nexthdr are sent over
    esp6 transport mode:

    [ 100.473845] kernel BUG at net/core/skbuff.c:4325!
    [ 100.478517] RIP: 0010:__skb_to_sgvec+0x252/0x260
    [ 100.494355] Call Trace:
    [ 100.494829] skb_to_sgvec+0x11/0x40
    [ 100.495492] esp6_output_tail+0x12e/0x550 [esp6]
    [ 100.496358] esp6_xmit+0x1d5/0x260 [esp6_offload]
    [ 100.498029] validate_xmit_xfrm+0x22f/0x2e0
    [ 100.499604] __dev_queue_xmit+0x589/0x910
    [ 100.502928] ip6_finish_output2+0x2a5/0x5a0
    [ 100.503718] ip6_output+0x6c/0x120
    [ 100.505198] xfrm_output_resume+0x4bf/0x530
    [ 100.508683] xfrm6_output+0x3a/0xc0
    [ 100.513446] inet6_csk_xmit+0xa1/0xf0
    [ 100.517335] tcp_sendmsg+0x27/0x40
    [ 100.517977] sock_sendmsg+0x3e/0x60
    [ 100.518648] __sys_sendto+0xee/0x160

    Fixes: c35fe4106b92 ("xfrm: Add mode handlers for IPsec on layer 2")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit afcaf61be9d1dbdee5ec186d1dcc67b6b692180f upstream.

    For beet mode, when it's ipv6 inner address with nexthdrs set,
    the packet format might be:

    ----------------------------------------------------
    | outer | | dest | | | ESP | ESP |
    | IP hdr | ESP | opts.| TCP | Data | Trailer | ICV |
    ----------------------------------------------------

    The nexthdr from ESP could be NEXTHDR_HOP(0), so it should
    continue processing the packet when nexthdr returns 0 in
    xfrm_input(). Otherwise, when ipv6 nexthdr is set, the
    packet will be dropped.

    I don't see any error cases that nexthdr may return 0. So
    fix it by removing the check for nexthdr == 0.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long
    Signed-off-by: Steffen Klassert
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     
  • commit e2d4a80f93fcfaf72e2e20daf6a28e39c3b90677 upstream.

    On a non-forwarding 802.11s link between two fairly busy
    neighboring nodes (iperf with -P 16 at ~850MBit/s TCP;
    1733.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 4), so with
    frequent PREQ retries, usually after around 30-40 seconds the
    following crash would occur:

    [ 1110.822428] Unable to handle kernel read from unreadable memory at virtual address 00000000
    [ 1110.830786] Mem abort info:
    [ 1110.833573] Exception class = IABT (current EL), IL = 32 bits
    [ 1110.839494] SET = 0, FnV = 0
    [ 1110.842546] EA = 0, S1PTW = 0
    [ 1110.845678] user pgtable: 4k pages, 48-bit VAs, pgd = ffff800076386000
    [ 1110.852204] [0000000000000000] *pgd=00000000f6322003, *pud=00000000f62de003, *pmd=0000000000000000
    [ 1110.861167] Internal error: Oops: 86000004 [#1] PREEMPT SMP
    [ 1110.866730] Modules linked in: pppoe ppp_async batman_adv ath10k_pci ath10k_core ath pppox ppp_generic nf_conntrack_ipv6 mac80211 iptable_nat ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_FLOWOFFLOAD slhc nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack iptable_mangle iptable_filter ip_tables crc_ccitt compat nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 usb_storage xhci_plat_hcd xhci_pci xhci_hcd dwc3 usbcore usb_common
    [ 1110.932190] Process swapper/3 (pid: 0, stack limit = 0xffff0000090c8000)
    [ 1110.938884] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.14.162 #0
    [ 1110.944965] Hardware name: LS1043A RGW Board (DT)
    [ 1110.949658] task: ffff8000787a81c0 task.stack: ffff0000090c8000
    [ 1110.955568] PC is at 0x0
    [ 1110.958097] LR is at call_timer_fn.isra.27+0x24/0x78
    [ 1110.963055] pc : [] lr : [] pstate: 00400145
    [ 1110.970440] sp : ffff00000801be10
    [ 1110.973744] x29: ffff00000801be10 x28: ffff000008bf7018
    [ 1110.979047] x27: ffff000008bf87c8 x26: ffff000008c160c0
    [ 1110.984352] x25: 0000000000000000 x24: 0000000000000000
    [ 1110.989657] x23: dead000000000200 x22: 0000000000000000
    [ 1110.994959] x21: 0000000000000000 x20: 0000000000000101
    [ 1111.000262] x19: ffff8000787a81c0 x18: 0000000000000000
    [ 1111.005565] x17: ffff0000089167b0 x16: 0000000000000058
    [ 1111.010868] x15: ffff0000089167b0 x14: 0000000000000000
    [ 1111.016172] x13: ffff000008916788 x12: 0000000000000040
    [ 1111.021475] x11: ffff80007fda9af0 x10: 0000000000000001
    [ 1111.026777] x9 : ffff00000801bea0 x8 : 0000000000000004
    [ 1111.032080] x7 : 0000000000000000 x6 : ffff80007fda9aa8
    [ 1111.037383] x5 : ffff00000801bea0 x4 : 0000000000000010
    [ 1111.042685] x3 : ffff00000801be98 x2 : 0000000000000614
    [ 1111.047988] x1 : 0000000000000000 x0 : 0000000000000000
    [ 1111.053290] Call trace:
    [ 1111.055728] Exception stack(0xffff00000801bcd0 to 0xffff00000801be10)
    [ 1111.062158] bcc0: 0000000000000000 0000000000000000
    [ 1111.069978] bce0: 0000000000000614 ffff00000801be98 0000000000000010 ffff00000801bea0
    [ 1111.077798] bd00: ffff80007fda9aa8 0000000000000000 0000000000000004 ffff00000801bea0
    [ 1111.085618] bd20: 0000000000000001 ffff80007fda9af0 0000000000000040 ffff000008916788
    [ 1111.093437] bd40: 0000000000000000 ffff0000089167b0 0000000000000058 ffff0000089167b0
    [ 1111.101256] bd60: 0000000000000000 ffff8000787a81c0 0000000000000101 0000000000000000
    [ 1111.109075] bd80: 0000000000000000 dead000000000200 0000000000000000 0000000000000000
    [ 1111.116895] bda0: ffff000008c160c0 ffff000008bf87c8 ffff000008bf7018 ffff00000801be10
    [ 1111.124715] bdc0: ffff0000080ff29c ffff00000801be10 0000000000000000 0000000000400145
    [ 1111.132534] bde0: ffff8000787a81c0 ffff00000801bde8 0000ffffffffffff 000001029eb19be8
    [ 1111.140353] be00: ffff00000801be10 0000000000000000
    [ 1111.145220] [< (null)>] (null)
    [ 1111.149917] [] run_timer_softirq+0x184/0x398
    [ 1111.155741] [] __do_softirq+0x100/0x1fc
    [ 1111.161130] [] irq_exit+0x80/0xd8
    [ 1111.166002] [] __handle_domain_irq+0x88/0xb0
    [ 1111.171825] [] gic_handle_irq+0x68/0xb0
    [ 1111.177213] Exception stack(0xffff0000090cbe30 to 0xffff0000090cbf70)
    [ 1111.183642] be20: 0000000000000020 0000000000000000
    [ 1111.191461] be40: 0000000000000001 0000000000000000 00008000771af000 0000000000000000
    [ 1111.199281] be60: ffff000008c95180 0000000000000000 ffff000008c19360 ffff0000090cbef0
    [ 1111.207101] be80: 0000000000000810 0000000000000400 0000000000000098 ffff000000000000
    [ 1111.214920] bea0: 0000000000000001 ffff0000089167b0 0000000000000000 ffff0000089167b0
    [ 1111.222740] bec0: 0000000000000000 ffff000008c198e8 ffff000008bf7018 ffff000008c19000
    [ 1111.230559] bee0: 0000000000000000 0000000000000000 ffff8000787a81c0 ffff000008018000
    [ 1111.238380] bf00: ffff00000801c000 ffff00000913ba34 ffff8000787a81c0 ffff0000090cbf70
    [ 1111.246199] bf20: ffff0000080857cc ffff0000090cbf70 ffff0000080857d0 0000000000400145
    [ 1111.254020] bf40: ffff000008018000 ffff00000801c000 ffffffffffffffff ffff0000080fa574
    [ 1111.261838] bf60: ffff0000090cbf70 ffff0000080857d0
    [ 1111.266706] [] el1_irq+0xe8/0x18c
    [ 1111.271576] [] arch_cpu_idle+0x10/0x18
    [ 1111.276880] [] do_idle+0xec/0x1b8
    [ 1111.281748] [] cpu_startup_entry+0x20/0x28
    [ 1111.287399] [] secondary_start_kernel+0x104/0x110
    [ 1111.293662] Code: bad PC value
    [ 1111.296710] ---[ end trace 555b6ca4363c3edd ]---
    [ 1111.301318] Kernel panic - not syncing: Fatal exception in interrupt
    [ 1111.307661] SMP: stopping secondary CPUs
    [ 1111.311574] Kernel Offset: disabled
    [ 1111.315053] CPU features: 0x0002000
    [ 1111.318530] Memory Limit: none
    [ 1111.321575] Rebooting in 3 seconds..

    With some added debug output / delays we were able to push the crash from
    the timer callback runner into the callback function and by that shedding
    some light on which object holding the timer gets corrupted:

    [ 401.720899] Unable to handle kernel read from unreadable memory at virtual address 00000868
    [...]
    [ 402.335836] [] _raw_spin_lock_bh+0x14/0x48
    [ 402.341548] [] mesh_path_timer+0x10c/0x248 [mac80211]
    [ 402.348154] [] call_timer_fn.isra.27+0x24/0x78
    [ 402.354150] [] run_timer_softirq+0x184/0x398
    [ 402.359974] [] __do_softirq+0x100/0x1fc
    [ 402.365362] [] irq_exit+0x80/0xd8
    [ 402.370231] [] __handle_domain_irq+0x88/0xb0
    [ 402.376053] [] gic_handle_irq+0x68/0xb0

    The issue happens due to the following sequence of events:

    1) mesh_path_start_discovery():
    -> spin_unlock_bh(&mpath->state_lock) before mesh_path_sel_frame_tx()

    2) mesh_path_free_rcu()
    -> del_timer_sync(&mpath->timer)
    [...]
    -> kfree_rcu(mpath)

    3) mesh_path_start_discovery():
    -> mod_timer(&mpath->timer, ...)
    [...]
    -> rcu_read_unlock()

    4) mesh_path_free_rcu()'s kfree_rcu():
    -> kfree(mpath)

    5) mesh_path_timer() starts after timeout, using freed mpath object

    So a use-after-free issue due to a timer re-arming bug caused by an
    early spin-unlocking.

    This patch fixes this issue by re-checking if mpath is about to be
    free'd and if so bails out of re-arming the timer.

    Cc: stable@vger.kernel.org
    Fixes: 050ac52cbe1f ("mac80211: code for on-demand Hybrid Wireless Mesh Protocol")
    Cc: Simon Wunderlich
    Signed-off-by: Linus Lüssing
    Link: https://lore.kernel.org/r/20200522170413.14973-1-linus.luessing@c0d3.blue
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Linus Lüssing
     
  • commit 0bbab5f0301587cad4e923ccc49bb910db86162c upstream.

    Removing the "if (IS_ERR(dir)) dir = NULL;" check only works
    if we adjust the remaining code to not rely on it being NULL.
    Check IS_ERR_OR_NULL() before attempting to dereference it.

    I'm not actually entirely sure this fixes the syzbot crash as
    the kernel config indicates that they do have DEBUG_FS in the
    kernel, but this is what I found when looking there.

    Cc: stable@vger.kernel.org
    Fixes: d82574a8e5a4 ("cfg80211: no need to check return value of debugfs_create functions")
    Reported-by: syzbot+fd5332e429401bf42d18@syzkaller.appspotmail.com
    Reviewed-by: Greg Kroah-Hartman
    Link: https://lore.kernel.org/r/20200525113816.fc4da3ec3d4b.Ica63a110679819eaa9fb3bc1b7437d96b1fd187d@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • [ Upstream commit 890bd0f8997ae6ac0a367dd5146154a3963306dd ]

    OSD client should ignore cache/overlay flag if got redirect reply.
    Otherwise, the client hangs when the cache tier is in forward mode.

    [ idryomov: Redirects are effectively deprecated and no longer
    used or tested. The original tiering modes based on redirects
    are inherently flawed because redirects can race and reorder,
    potentially resulting in data corruption. The new proxy and
    readproxy tiering modes should be used instead of forward and
    readforward. Still marking for stable as obviously correct,
    though. ]

    Cc: stable@vger.kernel.org
    URL: https://tracker.ceph.com/issues/23296
    URL: https://tracker.ceph.com/issues/36406
    Signed-off-by: Jerry Lee
    Reviewed-by: Ilya Dryomov
    Signed-off-by: Ilya Dryomov
    Signed-off-by: Sasha Levin

    Jerry Lee
     
  • commit 635d9398178659d8ddba79dd061f9451cec0b4d1 upstream.

    We cannot free record on any transient error because it leads to
    losing previos data. Check socket error to know whether record must
    be freed or not.

    Fixes: d10523d0b3d7 ("net/tls: free the record on encryption error")
    Signed-off-by: Vadim Fedorenko
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Vadim Fedorenko
     
  • commit a7bff11f6f9afa87c25711db8050c9b5324db0e2 upstream.

    bpf_exec_tx_verdict() can return negative value for copied
    variable. In that case this value will be pushed back to caller
    and the real error code will be lost. Fix it using signed type and
    checking for positive value.

    Fixes: d10523d0b3d7 ("net/tls: free the record on encryption error")
    Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
    Signed-off-by: Vadim Fedorenko
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Vadim Fedorenko
     
  • [ Upstream commit 1378817486d6860f6a927f573491afe65287abf1 ]

    dst_cache_get() documents it must be used with BH disabled.

    sysbot reported :

    BUG: using smp_processor_id() in preemptible [00000000] code: /21697
    caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
    CPU: 0 PID: 21697 Comm: Not tainted 5.7.0-rc6-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x188/0x20d lib/dump_stack.c:118
    check_preemption_disabled lib/smp_processor_id.c:47 [inline]
    debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
    dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
    tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
    tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
    tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
    tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
    __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
    tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
    genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
    genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
    genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
    netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
    genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
    netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
    netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
    netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
    sock_sendmsg_nosec net/socket.c:652 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:672
    ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
    ___sys_sendmsg+0x100/0x170 net/socket.c:2416
    __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
    do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
    entry_SYSCALL_64_after_hwframe+0x49/0xb3
    RIP: 0033:0x45ca29

    Fixes: e9c1a793210f ("tipc: add dst_cache support for udp media")
    Cc: Xin Long
    Cc: Jon Maloy
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit d3e8e4c11870413789f029a71e72ae6e971fe678 ]

    Commit bdf6fa52f01b ("sctp: handle association restarts when the
    socket is closed.") starts shutdown when an association is restarted,
    if in SHUTDOWN-PENDING state and the socket is closed. However, the
    rationale stated in that commit applies also when in SHUTDOWN-SENT
    state - we don't want to move an association to ESTABLISHED state when
    the socket has been closed, because that results in an association
    that is unreachable from user space.

    The problem scenario:

    1. Client crashes and/or restarts.

    2. Server (using one-to-one socket) calls close(). SHUTDOWN is lost.

    3. Client reconnects using the same addresses and ports.

    4. Server's association is restarted. The association and the socket
    move to ESTABLISHED state, even though the server process has
    closed its descriptor.

    Also, after step 4 when the server process exits, some resources are
    leaked in an attempt to release the underlying inet sock structure in
    ESTABLISHED state:

    IPv4: Attempt to release TCP socket in state 1 00000000377288c7

    Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
    an association is restarted in SHUTDOWN-SENT state and the socket is
    closed, then start shutdown and don't move the association or the
    socket to ESTABLISHED state.

    Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is closed.")
    Signed-off-by: Jere Leppänen
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Jere Leppänen
     
  • [ Upstream commit 20a785aa52c82246055a089e55df9dac47d67da1 ]

    This BUG halt was reported a while back, but the patch somehow got
    missed:

    PID: 2879 TASK: c16adaa0 CPU: 1 COMMAND: "sctpn"
    #0 [f418dd28] crash_kexec at c04a7d8c
    #1 [f418dd7c] oops_end at c0863e02
    #2 [f418dd90] do_invalid_op at c040aaca
    #3 [f418de28] error_code (via invalid_op) at c08631a5
    EAX: f34baac0 EBX: 00000090 ECX: f418deb0 EDX: f5542950 EBP: 00000000
    DS: 007b ESI: f34ba800 ES: 007b EDI: f418dea0 GS: 00e0
    CS: 0060 EIP: c046fa5e ERR: ffffffff EFLAGS: 00010286
    #4 [f418de5c] add_timer at c046fa5e
    #5 [f418de68] sctp_do_sm at f8db8c77 [sctp]
    #6 [f418df30] sctp_primitive_SHUTDOWN at f8dcc1b5 [sctp]
    #7 [f418df48] inet_shutdown at c080baf9
    #8 [f418df5c] sys_shutdown at c079eedf
    #9 [f418df70] sys_socketcall at c079fe88
    EAX: ffffffda EBX: 0000000d ECX: bfceea90 EDX: 0937af98
    DS: 007b ESI: 0000000c ES: 007b EDI: b7150ae4
    SS: 007b ESP: bfceea7c EBP: bfceeaa8 GS: 0033
    CS: 0073 EIP: b775c424 ERR: 00000066 EFLAGS: 00000282

    It appears that the side effect that starts the shutdown timer was processed
    multiple times, which can happen as multiple paths can trigger it. This of
    course leads to the BUG halt in add_timer getting called.

    Fix seems pretty straightforward, just check before the timer is added if its
    already been started. If it has mod the timer instead to min(current
    expiration, new expiration)

    Its been tested but not confirmed to fix the problem, as the issue has only
    occured in production environments where test kernels are enjoined from being
    installed. It appears to be a sane fix to me though. Also, recentely,
    Jere found a reproducer posted on list to confirm that this resolves the
    issues

    Signed-off-by: Neil Horman
    CC: Vlad Yasevich
    CC: "David S. Miller"
    CC: jere.leppanen@nokia.com
    CC: marcelo.leitner@gmail.com
    CC: netdev@vger.kernel.org
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Neil Horman
     
  • [ Upstream commit 84be69b869a5a496a6cfde9b3c29509207a1f1fa ]

    For nexthop groups, attributes after NHA_GROUP_TYPE are invalid, but
    nh_check_attr_group starts checking at NHA_GROUP. The group type defaults
    to multipath and the NHA_GROUP_TYPE is currently optional so this has
    slipped through so far. Fix the attribute checking to handle support of
    new group types.

    Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
    Signed-off-by: ASSOGBA Emery
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    David Ahern
     
  • [ Upstream commit 0cada33241d9de205522e3858b18e506ca5cce2c ]

    tls_sw_recvmsg() and tls_decrypt_done() can be run concurrently.
    // tls_sw_recvmsg()
    if (atomic_read(&ctx->decrypt_pending))
    crypto_wait_req(-EINPROGRESS, &ctx->async_wait);
    else
    reinit_completion(&ctx->async_wait.completion);

    //tls_decrypt_done()
    pending = atomic_dec_return(&ctx->decrypt_pending);

    if (!pending && READ_ONCE(ctx->async_notify))
    complete(&ctx->async_wait.completion);

    Consider the scenario tls_decrypt_done() is about to run complete()

    if (!pending && READ_ONCE(ctx->async_notify))

    and tls_sw_recvmsg() reads decrypt_pending == 0, does reinit_completion(),
    then tls_decrypt_done() runs complete(). This sequence of execution
    results in wrong completion. Consequently, for next decrypt request,
    it will not wait for completion, eventually on connection close, crypto
    resources freed, there is no way to handle pending decrypt response.

    This race condition can be avoided by having atomic_read() mutually
    exclusive with atomic_dec_return(),complete().Intoduced spin lock to
    ensure the mutual exclution.

    Addressed similar problem in tx direction.

    v1->v2:
    - More readable commit message.
    - Corrected the lock to fix new race scenario.
    - Removed barrier which is not needed now.

    Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    Signed-off-by: Vinay Kumar Yadav
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Vinay Kumar Yadav
     
  • [ Upstream commit a6211caa634da39d861a47437ffcda8b38ef421b ]

    Commit adb03115f459 ("net: get rid of an signed integer overflow in ip_idents_reserve()")
    used atomic_cmpxchg to replace "atomic_add_return" inside the function
    "ip_idents_reserve". The reason was to avoid UBSAN warning.
    However, this change has caused performance degrade and in GCC-8,
    fno-strict-overflow is now mapped to -fwrapv -fwrapv-pointer
    and signed integer overflow is now undefined by default at all
    optimization levels[1]. Moreover, it was a bug in UBSAN vs -fwrapv
    /-fno-strict-overflow, so Let's revert it safely.

    [1] https://gcc.gnu.org/gcc-8/changes.html

    Suggested-by: Peter Zijlstra
    Suggested-by: Eric Dumazet
    Cc: "David S. Miller"
    Cc: Alexey Kuznetsov
    Cc: Hideaki YOSHIFUJI
    Cc: Jakub Kicinski
    Cc: Jiri Pirko
    Cc: Arvind Sankar
    Cc: Peter Zijlstra
    Cc: Eric Dumazet
    Cc: Jiong Wang
    Signed-off-by: Yuqi Jin
    Signed-off-by: Shaokun Zhang
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Yuqi Jin
     
  • [ Upstream commit d28ea1fbbf437054ef339afec241019f2c4e2bb6 ]

    Once the traversal of the list is completed with list_for_each_entry(),
    the iterator (node) will point to an invalid object. So passing this to
    qrtr_local_enqueue() which is outside of the iterator block is erroneous
    eventhough the object is not used.

    So fix this by passing NULL to qrtr_local_enqueue().

    Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
    Reported-by: kbuild test robot
    Reported-by: Julia Lawall
    Signed-off-by: Manivannan Sadhasivam
    Reviewed-by: Bjorn Andersson
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Manivannan Sadhasivam