1. 12 5月, 2021 2 次提交
  2. 11 5月, 2021 4 次提交
  3. 08 5月, 2021 1 次提交
  4. 07 5月, 2021 3 次提交
    • E
      netfilter: nftables: avoid potential overflows on 32bit arches · 6c8774a9
      Eric Dumazet 提交于
      User space could ask for very large hash tables, we need to make sure
      our size computations wont overflow.
      
      nf_tables_newset() needs to double check the u64 size
      will fit into size_t field.
      
      Fixes: 0ed6389c ("netfilter: nf_tables: rename set implementations")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      6c8774a9
    • E
      netfilter: nftables: avoid overflows in nft_hash_buckets() · a54754ec
      Eric Dumazet 提交于
      Number of buckets being stored in 32bit variables, we have to
      ensure that no overflows occur in nft_hash_buckets()
      
      syzbot injected a size == 0x40000000 and reported:
      
      UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13
      shift exponent 64 is too large for 64-bit type 'long unsigned int'
      CPU: 1 PID: 29539 Comm: syz-executor.4 Not tainted 5.12.0-rc7-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x141/0x1d7 lib/dump_stack.c:120
       ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
       __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
       __roundup_pow_of_two include/linux/log2.h:57 [inline]
       nft_hash_buckets net/netfilter/nft_set_hash.c:411 [inline]
       nft_hash_estimate.cold+0x19/0x1e net/netfilter/nft_set_hash.c:652
       nft_select_set_ops net/netfilter/nf_tables_api.c:3586 [inline]
       nf_tables_newset+0xe62/0x3110 net/netfilter/nf_tables_api.c:4322
       nfnetlink_rcv_batch+0xa09/0x24b0 net/netfilter/nfnetlink.c:488
       nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:612 [inline]
       nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:630
       netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
       netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
       netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:674
       ____sys_sendmsg+0x6e8/0x810 net/socket.c:2350
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2404
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
       do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
      
      Fixes: 0ed6389c ("netfilter: nf_tables: rename set implementations")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      a54754ec
    • A
      tcp: Specify cmsgbuf is user pointer for receive zerocopy. · a6f8ee58
      Arjun Roy 提交于
      A prior change (1f466e1f) introduces separate handling for
      ->msg_control depending on whether the pointer is a kernel or user
      pointer. However, while tcp receive zerocopy is using this field, it
      is not properly annotating that the buffer in this case is a user
      pointer. This can cause faults when the improper mechanism is used
      within put_cmsg().
      
      This patch simply annotates tcp receive zerocopy's use as explicitly
      being a user pointer.
      
      Fixes: 7eeba170 ("tcp: Add receive timestamp support for receive zerocopy.")
      Signed-off-by: NArjun Roy <arjunroy@google.com>
      Acked-by: NSoheil Hassas Yeganeh <soheil@google.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20210506223530.2266456-1-arjunroy.kdev@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      a6f8ee58
  5. 06 5月, 2021 5 次提交
  6. 05 5月, 2021 3 次提交
    • E
      netfilter: nfnetlink: add a missing rcu_read_unlock() · 7072a355
      Eric Dumazet 提交于
      Reported by syzbot :
      BUG: sleeping function called from invalid context at include/linux/sched/mm.h:201
      in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 26899, name: syz-executor.5
      1 lock held by syz-executor.5/26899:
       #0: ffffffff8bf797a0 (rcu_read_lock){....}-{1:2}, at: nfnetlink_get_subsys net/netfilter/nfnetlink.c:148 [inline]
       #0: ffffffff8bf797a0 (rcu_read_lock){....}-{1:2}, at: nfnetlink_rcv_msg+0x1da/0x1300 net/netfilter/nfnetlink.c:226
      Preemption disabled at:
      [<ffffffff8917799e>] preempt_schedule_irq+0x3e/0x90 kernel/sched/core.c:5533
      CPU: 1 PID: 26899 Comm: syz-executor.5 Not tainted 5.12.0-next-20210504-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x141/0x1d7 lib/dump_stack.c:120
       ___might_sleep.cold+0x1f1/0x237 kernel/sched/core.c:8338
       might_alloc include/linux/sched/mm.h:201 [inline]
       slab_pre_alloc_hook mm/slab.h:500 [inline]
       slab_alloc_node mm/slub.c:2845 [inline]
       kmem_cache_alloc_node+0x33d/0x3e0 mm/slub.c:2960
       __alloc_skb+0x20b/0x340 net/core/skbuff.c:413
       alloc_skb include/linux/skbuff.h:1107 [inline]
       nlmsg_new include/net/netlink.h:953 [inline]
       netlink_ack+0x1ed/0xaa0 net/netlink/af_netlink.c:2437
       netlink_rcv_skb+0x33d/0x420 net/netlink/af_netlink.c:2508
       nfnetlink_rcv+0x1ac/0x420 net/netfilter/nfnetlink.c:650
       netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
       netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
       netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:674
       ____sys_sendmsg+0x6e8/0x810 net/socket.c:2350
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2404
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
       do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x4665f9
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fa8a03ee188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 00000000004665f9
      RDX: 0000000000000000 RSI: 0000000020000480 RDI: 0000000000000004
      RBP: 00000000004bfce1 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
      R13: 00007fffe864480f R14: 00007fa8a03ee300 R15: 0000000000022000
      
      ================================================
      WARNING: lock held when returning to user space!
      5.12.0-next-20210504-syzkaller #0 Tainted: G        W
      ------------------------------------------------
      syz-executor.5/26899 is leaving the kernel with locks still held!
      1 lock held by syz-executor.5/26899:
       #0: ffffffff8bf797a0 (rcu_read_lock){....}-{1:2}, at: nfnetlink_get_subsys net/netfilter/nfnetlink.c:148 [inline]
       #0: ffffffff8bf797a0 (rcu_read_lock){....}-{1:2}, at: nfnetlink_rcv_msg+0x1da/0x1300 net/netfilter/nfnetlink.c:226
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 26899 at kernel/rcu/tree_plugin.h:359 rcu_note_context_switch+0xfd/0x16e0 kernel/rcu/tree_plugin.h:359
      Modules linked in:
      CPU: 0 PID: 26899 Comm: syz-executor.5 Tainted: G        W         5.12.0-next-20210504-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:rcu_note_context_switch+0xfd/0x16e0 kernel/rcu/tree_plugin.h:359
      Code: 48 89 fa 48 c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 2e 0d 00 00 8b bd cc 03 00 00 85 ff 7e 02 <0f> 0b 65 48 8b 2c 25 00 f0 01 00 48 8d bd cc 03 00 00 48 b8 00 00
      RSP: 0000:ffffc90002fffdb0 EFLAGS: 00010002
      RAX: 0000000000000007 RBX: ffff8880b9c36080 RCX: ffffffff8dc99bac
      RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000001
      RBP: ffff88808b9d1c80 R08: 0000000000000000 R09: ffffffff8dc96917
      R10: fffffbfff1b92d22 R11: 0000000000000000 R12: 0000000000000000
      R13: ffff88808b9d1c80 R14: ffff88808b9d1c80 R15: ffffc90002ff8000
      FS:  00007fa8a03ee700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f09896ed000 CR3: 0000000032070000 CR4: 00000000001526f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       __schedule+0x214/0x23e0 kernel/sched/core.c:5044
       schedule+0xcf/0x270 kernel/sched/core.c:5226
       exit_to_user_mode_loop kernel/entry/common.c:162 [inline]
       exit_to_user_mode_prepare+0x13e/0x280 kernel/entry/common.c:208
       irqentry_exit_to_user_mode+0x5/0x40 kernel/entry/common.c:314
       asm_sysvec_reschedule_ipi+0x12/0x20 arch/x86/include/asm/idtentry.h:637
      RIP: 0033:0x4665f9
      
      Fixes: 50f2db9e ("netfilter: nfnetlink: consolidate callback types")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      7072a355
    • O
      net/nfc: fix use-after-free llcp_sock_bind/connect · c61760e6
      Or Cohen 提交于
      Commits 8a4cd82d ("nfc: fix refcount leak in llcp_sock_connect()")
      and c33b1cc6 ("nfc: fix refcount leak in llcp_sock_bind()")
      fixed a refcount leak bug in bind/connect but introduced a
      use-after-free if the same local is assigned to 2 different sockets.
      
      This can be triggered by the following simple program:
          int sock1 = socket( AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP );
          int sock2 = socket( AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP );
          memset( &addr, 0, sizeof(struct sockaddr_nfc_llcp) );
          addr.sa_family = AF_NFC;
          addr.nfc_protocol = NFC_PROTO_NFC_DEP;
          bind( sock1, (struct sockaddr*) &addr, sizeof(struct sockaddr_nfc_llcp) )
          bind( sock2, (struct sockaddr*) &addr, sizeof(struct sockaddr_nfc_llcp) )
          close(sock1);
          close(sock2);
      
      Fix this by assigning NULL to llcp_sock->local after calling
      nfc_llcp_local_put.
      
      This addresses CVE-2021-23134.
      Reported-by: NOr Cohen <orcohen@paloaltonetworks.com>
      Reported-by: NNadav Markus <nmarkus@paloaltonetworks.com>
      Fixes: c33b1cc6 ("nfc: fix refcount leak in llcp_sock_bind()")
      Signed-off-by: NOr Cohen <orcohen@paloaltonetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c61760e6
    • J
      net: Only allow init netns to set default tcp cong to a restricted algo · 8d432592
      Jonathon Reinhart 提交于
      tcp_set_default_congestion_control() is netns-safe in that it writes
      to &net->ipv4.tcp_congestion_control, but it also sets
      ca->flags |= TCP_CONG_NON_RESTRICTED which is not namespaced.
      This has the unintended side-effect of changing the global
      net.ipv4.tcp_allowed_congestion_control sysctl, despite the fact that it
      is read-only: 97684f09 ("net: Make tcp_allowed_congestion_control
      readonly in non-init netns")
      
      Resolve this netns "leak" by only allowing the init netns to set the
      default algorithm to one that is restricted. This restriction could be
      removed if tcp_allowed_congestion_control were namespace-ified in the
      future.
      
      This bug was uncovered with
      https://github.com/JonathonReinhart/linux-netns-sysctl-verify
      
      Fixes: 6670e152 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control")
      Signed-off-by: NJonathon Reinhart <jonathon.reinhart@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8d432592
  7. 04 5月, 2021 10 次提交
  8. 02 5月, 2021 2 次提交
    • C
      xprtrdma: Fix a NULL dereference in frwr_unmap_sync() · 9e895cd9
      Chuck Lever 提交于
      The normal mechanism that invalidates and unmaps MRs is
      frwr_unmap_async(). frwr_unmap_sync() is used only when an RPC
      Reply bearing Write or Reply chunks has been lost (ie, almost
      never).
      
      Coverity found that after commit 9a301caf ("xprtrdma: Move
      fr_linv_done field to struct rpcrdma_mr"), the while() loop in
      frwr_unmap_sync() exits only once @mr is NULL, unconditionally
      causing subsequent dereferences of @mr to Oops.
      
      I've tested this fix by creating a client that skips invoking
      frwr_unmap_async() when RPC Replies complete. That forces all
      invalidation tasks to fall upon frwr_unmap_sync(). Simple workloads
      with this fix applied to the adulterated client work as designed.
      Reported-by: Ncoverity-bot <keescook+coverity-bot@chromium.org>
      Addresses-Coverity-ID: 1504556 ("Null pointer dereferences")
      Fixes: 9a301caf ("xprtrdma: Move fr_linv_done field to struct rpcrdma_mr")
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
      9e895cd9
    • B
      sunrpc: Fix misplaced barrier in call_decode · f8f7e0fb
      Baptiste Lepers 提交于
      Fix a misplaced barrier in call_decode. The struct rpc_rqst is modified
      as follows by xprt_complete_rqst:
      
      req->rq_private_buf.len = copied;
      /* Ensure all writes are done before we update */
      /* req->rq_reply_bytes_recvd */
      smp_wmb();
      req->rq_reply_bytes_recvd = copied;
      
      And currently read as follows by call_decode:
      
      smp_rmb(); // misplaced
      if (!req->rq_reply_bytes_recvd)
         goto out;
      req->rq_rcv_buf.len = req->rq_private_buf.len;
      
      This patch places the smp_rmb after the if to ensure that
      rq_reply_bytes_recvd and rq_private_buf.len are read in order.
      
      Fixes: 9ba82886 ("SUNRPC: Don't try to parse incomplete RPC messages")
      Signed-off-by: NBaptiste Lepers <baptiste.lepers@gmail.com>
      Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
      f8f7e0fb
  9. 01 5月, 2021 8 次提交
  10. 30 4月, 2021 2 次提交
    • Y
      net: Remove redundant assignment to err · 1a70f659
      Yang Li 提交于
      Variable 'err' is set to -ENOMEM but this value is never read as it is
      overwritten with a new value later on, hence the 'If statements' and
      assignments are redundantand and can be removed.
      
      Cleans up the following clang-analyzer warning:
      
      net/ipv6/seg6.c:126:4: warning: Value stored to 'err' is never read
      [clang-analyzer-deadcode.DeadStores]
      Reported-by: NAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: NYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1a70f659
    • Z
      bridge: Fix possible races between assigning rx_handler_data and setting IFF_BRIDGE_PORT bit · 59259ff7
      Zhang Zhengming 提交于
      There is a crash in the function br_get_link_af_size_filtered,
      as the port_exists(dev) is true and the rx_handler_data of dev is NULL.
      But the rx_handler_data of dev is correct saved in vmcore.
      
      The oops looks something like:
       ...
       pc : br_get_link_af_size_filtered+0x28/0x1c8 [bridge]
       ...
       Call trace:
        br_get_link_af_size_filtered+0x28/0x1c8 [bridge]
        if_nlmsg_size+0x180/0x1b0
        rtnl_calcit.isra.12+0xf8/0x148
        rtnetlink_rcv_msg+0x334/0x370
        netlink_rcv_skb+0x64/0x130
        rtnetlink_rcv+0x28/0x38
        netlink_unicast+0x1f0/0x250
        netlink_sendmsg+0x310/0x378
        sock_sendmsg+0x4c/0x70
        __sys_sendto+0x120/0x150
        __arm64_sys_sendto+0x30/0x40
        el0_svc_common+0x78/0x130
        el0_svc_handler+0x38/0x78
        el0_svc+0x8/0xc
      
      In br_add_if(), we found there is no guarantee that
      assigning rx_handler_data to dev->rx_handler_data
      will before setting the IFF_BRIDGE_PORT bit of priv_flags.
      So there is a possible data competition:
      
      CPU 0:                                                        CPU 1:
      (RCU read lock)                                               (RTNL lock)
      rtnl_calcit()                                                 br_add_slave()
        if_nlmsg_size()                                               br_add_if()
          br_get_link_af_size_filtered()                              -> netdev_rx_handler_register
                                                                          ...
                                                                          // The order is not guaranteed
            ...                                                           -> dev->priv_flags |= IFF_BRIDGE_PORT;
            // The IFF_BRIDGE_PORT bit of priv_flags has been set
            -> if (br_port_exists(dev)) {
              // The dev->rx_handler_data has NOT been assigned
              -> p = br_port_get_rcu(dev);
              ....
                                                                          -> rcu_assign_pointer(dev->rx_handler_data, rx_handler_data);
                                                                           ...
      
      Fix it in br_get_link_af_size_filtered, using br_port_get_check_rcu() and checking the return value.
      Signed-off-by: NZhang Zhengming <zhangzhengming@huawei.com>
      Reviewed-by: NZhao Lei <zhaolei69@huawei.com>
      Reviewed-by: NWang Xiaogang <wangxiaogang3@huawei.com>
      Suggested-by: NNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59259ff7