1. 05 Dec, 2023 2 commits
    • Hou Tao's avatar
      bpf: Add map and need_defer parameters to .map_fd_put_ptr() · 20c20bd1
      Hou Tao authored
      map is the pointer of outer map, and need_defer needs some explanation.
      need_defer tells the implementation to defer the reference release of
      the passed element and ensure that the element is still alive before
      the bpf program, which may manipulate it, exits.
      
      The following three cases will invoke map_fd_put_ptr() and different
      need_defer values will be passed to these callers:
      
      1) release the reference of the old element in the map during map update
         or map deletion. The release must be deferred, otherwise the bpf
         program may incur use-after-free problem, so need_defer needs to be
         true.
      2) release the reference of the to-be-added element in the error path of
         map update. The to-be-added element is not visible to any bpf
         program, so it is OK to pass false for need_defer parameter.
      3) release the references of all elements in the map during map release.
         Any bpf program which has access to the map must have been exited and
         released, so need_defer=false will be OK.
      
      These two parameters will be used by the following patches to fix the
      potential use-after-free problem for map-in-map.
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Link: https://lore.kernel.org/r/20231204140425.1480317-3-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      20c20bd1
    • Hou Tao's avatar
      bpf: Check rcu_read_lock_trace_held() before calling bpf map helpers · 169410eb
      Hou Tao authored
      These three bpf_map_{lookup,update,delete}_elem() helpers are also
      available for sleepable bpf program, so add the corresponding lock
      assertion for sleepable bpf program, otherwise the following warning
      will be reported when a sleepable bpf program manipulates bpf map under
      interpreter mode (aka bpf_jit_enable=0):
      
        WARNING: CPU: 3 PID: 4985 at kernel/bpf/helpers.c:40 ......
        CPU: 3 PID: 4985 Comm: test_progs Not tainted 6.6.0+ #2
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) ......
        RIP: 0010:bpf_map_lookup_elem+0x54/0x60
        ......
        Call Trace:
         <TASK>
         ? __warn+0xa5/0x240
         ? bpf_map_lookup_elem+0x54/0x60
         ? report_bug+0x1ba/0x1f0
         ? handle_bug+0x40/0x80
         ? exc_invalid_op+0x18/0x50
         ? asm_exc_invalid_op+0x1b/0x20
         ? __pfx_bpf_map_lookup_elem+0x10/0x10
         ? rcu_lockdep_current_cpu_online+0x65/0xb0
         ? rcu_is_watching+0x23/0x50
         ? bpf_map_lookup_elem+0x54/0x60
         ? __pfx_bpf_map_lookup_elem+0x10/0x10
         ___bpf_prog_run+0x513/0x3b70
         __bpf_prog_run32+0x9d/0xd0
         ? __bpf_prog_enter_sleepable_recur+0xad/0x120
         ? __bpf_prog_enter_sleepable_recur+0x3e/0x120
         bpf_trampoline_6442580665+0x4d/0x1000
         __x64_sys_getpgid+0x5/0x30
         ? do_syscall_64+0x36/0xb0
         entry_SYSCALL_64_after_hwframe+0x6e/0x76
         </TASK>
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Link: https://lore.kernel.org/r/20231204140425.1480317-2-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      169410eb
  2. 04 Dec, 2023 2 commits
  3. 02 Dec, 2023 19 commits
  4. 01 Dec, 2023 16 commits
  5. 30 Nov, 2023 1 commit
    • Linus Torvalds's avatar
      Merge tag 'net-6.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 6172a518
      Linus Torvalds authored
      Pull networking fixes from Paolo Abeni:
       "Including fixes from bpf and wifi.
      
        Current release - regressions:
      
         - neighbour: fix __randomize_layout crash in struct neighbour
      
         - r8169: fix deadlock on RTL8125 in jumbo mtu mode
      
        Previous releases - regressions:
      
         - wifi:
             - mac80211: fix warning at station removal time
             - cfg80211: fix CQM for non-range use
      
         - tools: ynl-gen: fix unexpected response handling
      
         - octeontx2-af: fix possible buffer overflow
      
         - dpaa2: recycle the RX buffer only after all processing done
      
         - rswitch: fix missing dev_kfree_skb_any() in error path
      
        Previous releases - always broken:
      
         - ipv4: fix uaf issue when receiving igmp query packet
      
         - wifi: mac80211: fix debugfs deadlock at device removal time
      
         - bpf:
             - sockmap: af_unix stream sockets need to hold ref for pair sock
             - netdevsim: don't accept device bound programs
      
         - selftests: fix a char signedness issue
      
         - dsa: mv88e6xxx: fix marvell 6350 probe crash
      
         - octeontx2-pf: restore TC ingress police rules when interface is up
      
         - wangxun: fix memory leak on msix entry
      
         - ravb: keep reverse order of operations in ravb_remove()"
      
      * tag 'net-6.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (51 commits)
        net: ravb: Keep reverse order of operations in ravb_remove()
        net: ravb: Stop DMA in case of failures on ravb_open()
        net: ravb: Start TX queues after HW initialization succeeded
        net: ravb: Make write access to CXR35 first before accessing other EMAC registers
        net: ravb: Use pm_runtime_resume_and_get()
        net: ravb: Check return value of reset_control_deassert()
        net: libwx: fix memory leak on msix entry
        ice: Fix VF Reset paths when interface in a failed over aggregate
        bpf, sockmap: Add af_unix test with both sockets in map
        bpf, sockmap: af_unix stream sockets need to hold ref for pair sock
        tools: ynl-gen: always construct struct ynl_req_state
        ethtool: don't propagate EOPNOTSUPP from dumps
        ravb: Fix races between ravb_tx_timeout_work() and net related ops
        r8169: prevent potential deadlock in rtl8169_close
        r8169: fix deadlock on RTL8125 in jumbo mtu mode
        neighbour: Fix __randomize_layout crash in struct neighbour
        octeontx2-pf: Restore TC ingress police rules when interface is up
        octeontx2-pf: Fix adding mbox work queue entry when num_vfs > 64
        net: stmmac: xgmac: Disable FPE MMC interrupts
        octeontx2-af: Fix possible buffer overflow
        ...
      6172a518