summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf
AgeCommit message (Collapse)Author
4 daysMerge tag 'vfs-7.4-rc1.fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs Pull vfs fixes from Christian Brauner: - writeback: - Update dirtied_when instead of dirtied_time_when when a wb switch puts an inode at the newest end of the target b_dirty list. The list was left out of order so move_expired_inodes() could stop before older inodes, and the lazytime expiration timestamp was reset - Clear the old wb's dirty-I/O state and bandwidth contribution when a batch of inode switches leaves its dirty lists empty. An empty wb stayed scheduled for periodic writeback and inflated bdi->tot_write_bandwidth - Take wb_switch_rwsem across the inode scan of cleanup_offline_cgwb(). The v7.3-rc5 fix that rotates scanned inodes let a scan racing a sync()'s queue_io() move lazytime inodes past the sync's cutoff, so sync() returned without persisting their timestamps - Don't kick writeback for an IOCB_DONTCACHE write on an inode that has no wb yet. With cgroup writeback an O_DIRECT RWF_DONTCACHE write to a block device dereferenced NULL - statmount/listmount/listns: - Refuse statmount() string requests with a buffer that isn't larger than struct statmount - Don't wrap around with a U64_MAX cursor in listmount() and listns() - Don't end listns() at an inactive namespace - Only add init_ipc_ns and init_net to the namespace trees if CONFIG_IPC_NS and CONFIG_NET_NS are enabled - iomap: - Only mark blocks uptodate in __iomap_write_begin() after reading them and let __iomap_write_end() mark the zeroed blocks uptodate once the copy from userspace succeeded - Check a chunk against max_integrity_io_size() on its own before the bio size check - Only enforce block alignment for direct I/O into holes and unwritten extents if IOMAP_DIO_FSBLOCK_ALIGNED is set - backing-file: - Check S_APPEND and S_IMMUTABLE on the backing inode. FUSE passthrough opens the backing file with vfs_open() which skips may_open(), so anyone who may open the FUSE file for writing could overwrite an append-only backing file anywhere or write to an immutable one. Open, mmap and writes now check the backing inode the way may_open() and do_mmap() do - Always call kiocb_end_write() for a queued write - Let backing files inherit FMODE_NONOTIFY from the user file. The event fds fanotify creates for permission events on a stacked filesystem raised FS_OPEN_PERM on the real path from inside the listener's read() and deadlocked listeners with marks on both layers - pidfs: - Look the task up before checking for exit information in PIDFD_GET_INFO and start over if the task no longer owns the pid once all fields have been read. A caller racing release_task() got neither PIDFD_INFO_PID nor PIDFD_INFO_EXIT or ESRCH although the exit information was available, and a caller racing a sub-thread's exec reported that thread's tid as the pid - Clear the mask bits of fields that lie beyond the struct size the caller passed. The uapi header promises that the mask names no such field but a caller passing PIDFD_INFO_SIZE_VER0 got the coredump and supported mask bits set for fields that were never written - aio: - Give the aio ring a ->read_folio that fails with EIO so a fault on a ring whose file was truncated gets SIGBUS instead of jumping to NULL - Check nr_events against the ring size before doubling it in ioctx_alloc() - splice: - Only write back an implicit file position in do_splice() when the splice helper succeeded. splice doesn't take f_pos_lock so a failed splice restored a stale snapshot over a position that a concurrent getdents() had moved. On ext2 the next readdir then trusted an offset inside a directory entry - Retry tee() when the input pipe was emptied or the output pipe filled between the prep steps and link_pipe() instead of returning 0 while the input pipe still has writers, as splice_pipe_to_pipe() does - ucount: - Take the reference that pins a ucounts level on the 0 -> 1 transition before checking the rlimit - Read the parent ucounts before dropping the rlimit count in do_dec_rlimit_put_ucounts() - inode: - Rotate inodes whose page cache couldn't be dropped to the tail of the LRU - Skip inodes that another LRU walker is isolating - setns: - Set nsset->flags before anything in prepare_nsset() can fail so the error path drops the cred prepared for CLONE_NEWUSER. A failing setns() with CLONE_NEWUSER and CLONE_NEWNS leaked it together with its user namespace - Refuse setns(CLONE_NEWNS) for a task that shares its fs_struct again when more namespaces are requested - minix: - Restore uptodate on the pinned bitmap buffers before redirtying them after a failed writeback instead of tripping the warning in mark_buffer_dirty(), as ext2 and ext4 do for their superblock buffers - Reject rmdir() of a directory with a corrupted link count with EFSCORRUPTED instead of hitting the drop_nlink() warning - userns: Keep the exec securebits and their locks when creating or joining a user namespace. set_cred_user_ns() reset all securebits to SECUREBITS_DEFAULT so anyone who may create a user namespace could shed SECBIT_EXEC_RESTRICT_FILE and SECBIT_EXEC_DENY_INTERACTIVE with a single unshare(CLONE_NEWUSER) - fs: Honor FOP_UNSIGNED_OFFSET in sys_llseek() and in the pread64(), pwrite64(), preadv() and pwritev() wrappers - proc/kcore: Advance the vmalloc retry in read_kcore_iter() by the last vread_iter() copy instead of the running total - eventpoll: Return the error when the wakeup source for EPOLLWAKEUP can't be created in EPOLL_CTL_MOD instead of reporting success without suspend protection - coredump: Mark do_coredump() noinline_for_stack - nsfs: Check the trailing bytes of a namespace file handle in bytes instead of words - netfs: Restore the per-level and per-point decoding of the debug mask - exportfs: Release the directory file get_name() opened with __fput_sync(). From nfsd's kernel threads the deferred fputs arrived faster than delayed_fput retired them and each pinned the directory's readdir state, growing unreclaimable slab by about 90 MB per second under a parallel tree walk - fs: Call ramfs_kill_sb() for a ramfs rootfs. Since rootfs can be unmounted as of v7.0 its struct ramfs_fs_info was leaked - signal: Check the blocked mask for every entry dequeue_synchronous_signal() looks at. The scan could select a blocked synchronous signal and deliver it while blocked - super: Convert the superblock device table from an rhltable to a plain hashtable under a spinlock. This fixes a bug from v7.3 where fs_bdev_freeze() froze a btrfs filesystem through a stale member that open_ctree() had already released while the freeze was waiting for SB_BORN - fork: Leave rcu_users at zero until copy_process() can't fail anymore. bpf_task_acquire() handed out trusted references to the new task from the task_alloc LSM hook and sched_ext's ops.init_task() and a failing fork freed the task behind them - xattr: Always run cap_convert_nscap() for a security.capability write. A zero-length setxattr() skipped it and let an unprivileged caller without CAP_SETFCAP or write permission on the file plant an empty security.capability xattr that made every execve() of the binary fail with EINVAL - namei: Skip the S_ISDIR assertion in - proc: Refuse to mount on entries below /proc/<pid>/net like fd/, fdinfo/ and map_files/. proc_net_d_revalidate() always fails so the first lookup by anyone with search permission ran d_invalidate() on the dentry and detached every mount on it, locked mounts included - libfs: Hold one mount reference for all pins instead of one per pin. The pin count is what keeps the mount alive, so the per-pin reference only cost a mntget() and a mntput() through mntput_no_expire_slowpath() for every debugfs, tracefs, securityfs or configfs file that comes and goes - iov_iter: Return 0 from iov_iter_alignment() for an empty iterator of any type - watch_queue: Give info_id its own storage instead of overlaying it with rcu_head - filelock: Take an active superblock reference while waiting for a delegation break. After a lazy umount closing the delegation holder could shut down the superblock under the waiter whose final iput() then ran shmem_evict_inode() on freed state - fs: Skip the copy_file_range() write limit checks when there is no data to copy - bpf: Allow bpf_d_path() from fentry on filp_close_sync(). Since close_range() became synchronous this cycle close(), close_range() and the closes on exec and exit no longer go through filp_close(). fexit stays rejected since the file may be gone by then - fs_pin: Dequeue the wait entry unconditionally in pin_kill(). A spuriously woken waiter kept its on-stack entry queued, took that as proof that the pin was alive and used the freed acct structure when umount() of the accounting file raced acct(2) - dcache: Don't fail __d_obtain_alias() for an inode without links and aliases. The ESTALE check added this cycle broke open_by_handle_at() and nfsd file handle decoding on NFS and FUSE where i_nlink is just what the server last reported and the handle may well still be valid - selftests/ovl: Fix the mountinfo expectations of the detached layer test which has failed since it was added * tag 'vfs-7.4-rc1.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (60 commits) fs: don't fail __d_obtain_alias() for unlinked inodes ns: don't add init_ipc_ns and init_net without namespace support aio: avoid request count overflow in ioctx_alloc() selftests/ovl: fix detached layer mountinfo expectations bpf: Allow bpf_d_path() from filp_close_sync() fs: skip copy_file_range write limits when there is no data minix: reject rmdir of a directory with a corrupted link count fs_pin: do not trust the pin after a spurious wakeup in pin_kill() ucount: read the parent ucounts before dropping the rlimit count splice: retry tee() instead of returning 0 when it races selftests/pidfd: test that fields beyond the struct size are not reported pidfs: do not report fields that do not fit into the caller's struct fs: let backing files inherit FMODE_NONOTIFY from the user file splice: avoid stale f_pos writeback on error backing-file: always end a queued write filelock: keep superblock active through delegation wait watch_queue: keep info_id separate from rcu_head iomap: only follow dio alignment requirement if specified iov_iter: fix NULL deref in iov_iter_alignment() backing-file: enforce append-only and immutable backing inodes ...
4 daysbpf: Allow bpf_d_path() from filp_close_sync()Ihor Solodrai
The d_path selftest closes its descriptors with close_range() so that its fentry program on filp_close() runs. Commit 056069eb2b66 ("fs: make close_range() synchronous") switched close_range() to filp_close_sync(), so the program still attaches but is never called: test_d_path_basic:FAIL:close trampoline for filp_close was not called With that series, close(), close_range() and the closes on exec and exit all go through filp_close_sync(). Few paths still reach filp_close(), dup2() being one of them, so a program on filp_close() no longer sees most file closes. Allow bpf_d_path() from filp_close_sync(), but only from fentry. filp_close_sync() drops the last file reference inline, so by the time an fexit program runs, file->f_path may already be freed, with no RCU delay for NORCU dentries such as pipes and sockets. Attach the selftest program to filp_close_sync() and keep triggering it with close_range(). Add a test rejecting bpf_d_path() from fexit/filp_close_sync. Fixes: 056069eb2b66 ("fs: make close_range() synchronous") Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://patch.msgid.link/20261021201400.5409-1-ihor.solodrai@linux.dev Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
5 daysMerge tag 'net-7.4-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net Pull networking fixes from Jakub Kicinski: "Current release - new code bugs: - mctp: usblib: fix assertion breaking esoteric builds Previous releases - regressions: - Revert advertising the TCP MSS from the configured MTU - netlink: check sk_rcvbuf before charging the dump skb - eth: - ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl - mlx4: always create the eth and ib auxiliary devices - tg3: invert restart quirk logic to restrict SNP power-down bypass - bnxt: recycle agg buffers when Rx head buffer allocation fails Previous releases - always broken: - net: fix frag_list leak in skb_segment_list() error path - sctp: reject forged cookie peer_addr with unknown address family - vxlan: keep reserved_bits across changelink - net: limit priority VLAN untag depth - inet: frags: prevent acceptance of partially authenticated reassembly - gro: do not GRO GSO packets with inconsistent payload - tcp: avoid double destroy in tcp_abort() of an unaccepted child" * tag 'net-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (137 commits) tun: drop batched packets while the device is down selftests: net: netlink-dumps: start a dump with a notification queued netlink: check sk_rcvbuf before charging the dump skb net/sched: act_ife: do not consume the inner header on egress openvswitch: use eth_type_trans_careful() in internal_dev_recv() net: use eth_type_trans_careful() in __dev_forward_skb2() loopback: use eth_type_trans_careful() net: add eth_type_trans_careful() tcp: initialize mapped children before route lookup tcp: fix reordering addition overflow in MTU probing tcp: avoid double destroy in tcp_abort() of an unaccepted child net: bgmac: fix TX DMA unmapping and slot cleanup gro: do not GRO GSO packets with inconsistent payload net/packet: check TX_RING fragments before memory accounting eth: bnxt: hand XDP frags over to the copybreak skb eth: bnxt: free XDP frags when xdp_do_redirect() fails eth: bnxt: don't leak buffers when XDP agg buffer allocation fails eth: bnxt: resize Rx head buffers when rx-copybreak changes eth: bnxt: recycle agg buffers when Rx head buffer allocation fails netdev-genl: ignore NETDEV_UNREGISTER rebroadcasts ...
5 daysnet: use eth_type_trans_careful() in __dev_forward_skb2()Eric Dumazet
A tc egress BPF program can push a tiny link-layer header with bpf_skb_change_head() on an skb whose head is almost empty, then redirect it to an Ethernet device ingress. __bpf_redirect_common() only checks mac_header < network_header, and __dev_forward_skb2() crashes in eth_type_trans(): tc filter add dev lo egress pref 1 matchall action vlan pop_eth continue tc filter add dev lo egress pref 2 bpf da obj prog.o # prog: bpf_skb_change_head(skb, 1, 0); # return bpf_redirect(veth1_ifindex, BPF_F_INGRESS); # AF_PACKET SOCK_RAW on lo: eth / eth / 8192 bytes of payload kernel BUG at include/linux/skbuff.h:2839! RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163) Call Trace: __dev_forward_skb2 (net/core/dev.c:2507) dev_forward_skb_nomtu (net/core/dev.c:2546) __dev_queue_xmit (net/core/dev.c:4738 net/core/dev.c:4998) packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189) Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled. This also covers other dev_forward_skb() users (veth, macvlan, ipvlan, netdevsim, l2tp_eth). Update the empty_skb BPF selftest: at lwt_xmit, BPF_PROG_TEST_RUN strips the Ethernet header, so the "veth ETH_HLEN+1" packet is a 1-byte skb. Redirecting it to veth ingress used to read the Ethernet header past skb->tail and deliver a 1-byte frame; it is now dropped with NET_RX_DROP, as veth_xmit() already does at egress. Fixes: 3a0af8fd61f9 ("bpf: BPF for lightweight tunnel infrastructure") Signed-off-by: Eric Dumazet <edumazet@kernel.org> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Tested-by: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20261028122703.2093730-4-edumazet@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
6 daysselftests/bpf: Test stack arguments across may_gotoAlexei Starovoitov
Each test passes arguments 6-8 on the stack. Thus it uses all the registers in which the JITs of x86-64, arm64 and riscv64 pass stack arguments. may_goto then ------------------------------------------- --------------------------- 70000 iterations in the callee the callee reads the args the time is up in the callee the callee reads the args 70000 iterations in the caller, after the the caller calls the callee writes of the args 70000 iterations have one look at the clock. Without the fix on x86-64 the second test fails, and the first test fails with the hpet clocksource. The third test passes there. The result depends on the registers that the C code uses. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-20-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Test maybe_fork_scalars() at the head of a counted loopAlexei Starovoitov
The insn that forks is the head of a loop that scalar evolution counted. The state with 0 that maybe_fork_scalars() splits off is within the state that is kept at the head. The access is out of bounds only in the state with 0. Without the previous patch the verifier accepts the prog. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-18-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Test the clamp of pointers in scalar evolutionAlexei Starovoitov
test the loop result -------------------------------------- ------------------------- ------ clamp_released_pointer releases ringbuf memory reject clamp_invalidated_pkt_pointer calls bpf_skb_pull_data() reject clamp_pkt_pointer_keeps_no_range compares with pkt_end reject clamp_pkt_pointer_keeps_range_of_entry has no compare loads In the first three tests a flag in a 32-bit spill separates the first iteration from the second one. Scalar evolution does not widen the flag. Thus the verifier does not prune the state that returns to the head of the loop, and it verifies the second iteration with the clamped register. Without the fixes the three progs load. In the last test the compare with pkt_end is in front of the loop. Its range must stay valid in the loop. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-16-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Test a loop that moves a pointer to a bufferAlexei Starovoitov
ptr_buf moves one pointer to a buffer until it gets to a second pointer. It never reads through the pointer. It loads only if scalar evolution widens the pointer, and that is no longer the case. Change it to the loop that real progs have, for example bpf_iter_bpf_percpu_array_map.c. It counts in a register and reads through the pointer in each iteration. Without "bpf: Don't widen a pointer to a buffer in scalar evolution" the verifier rejects it with "invalid variable buffer offset". Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-13-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Avoid a page fault in rcu_reentry while the handler is armedAlexei Starovoitov
The test arms a handler at rcu_segcblist_enqueue() for its thread. Then it deletes an element of a task storage map. The delete gets to rcu_segcblist_enqueue(), and the handler does a nested delete there. The handler fires at the first rcu_segcblist_enqueue() in the thread. A page fault can be the first: skel->bss->target_pid = tid the handler is armed the next insn is in a page that is not in memory asm_exc_page_fault filemap_fault v9fs_issue_read p9_req_put irq_work_run rcu_defer_drain rcu_segcblist_enqueue the handler deletes the element bpf_map_delete_elem() -ENOENT test_rcu_reentry:FAIL:boot_delete unexpected error: -2 (errno 2) The result depends on the layout of test_progs. In the binary that failed, test_rcu_reentry() crosses the end of a page immediately after the store. This binary fails each time when it is on 9p. A copy of the same file on ext4 passes. Move the store and the delete to a function. Call it one time without a pid and with a bad fd. This call brings the text and .bss into memory, and it does not arm the handler. Fixes: 0464f587c61a ("selftests/bpf: Add a call_srcu() re-entry reproducer") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-11-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Wait for the last maps of map_kptr to be freedAlexei Starovoitov
map_kptr_race/htab_leak fails occasionally in a complete run of test_progs: test_htab_leak:FAIL:htab refcount unexpected htab refcount: actual 6 != expected 2 This is a race between two tests. It is not a leak in the kernel. - map_kptr runs immediately before htab_leak. The two tests examine the refcount of the same test object. - The kernel frees maps asynchronously. Thus the maps drop their references some time after close(). - map_kptr waits for that after each subtest, but not after the last one. Wait after the last subtest too. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-10-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Test that a widened register is not linkedAlexei Starovoitov
Scalar evolution widens a register that has delta 4. Then the prog copies the register. With the stale delta the verifier finds that a read of uninitialized r9 is dead code, and it loads the prog. See "bpf: Clear delta of a register that scalar evolution widens". Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-9-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Remove tests for arena access through numbersAlexei Starovoitov
With BPF_F_ARENA_SCALAR the verifier accepts a load or a store through a scalar as an access to arena. The next patch removes the flag. Remove its tests. Keep one test. Without the flag the verifier must reject such a load, also in a prog that has an arena. Move this test to verifier_arena.c. The removed tests were the only tests of a special path in the x86 JIT for the fetching AND/OR/XOR atomics. Only the flag used that path. arena_atomics tests the usual path. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-5-alexei.starovoitov@gmail.com
6 daysselftests/bpf: Remove tests for global data in arenaAlexei Starovoitov
The .arena.data section and the BPF_F_ARENA_SCALAR flag let a prog in Rust keep its global data in arena. The subsequent patches remove the two, because the compiler can do this work. First remove the tests for .arena.data. One of the tests is a prog in Rust. It has no replacement, because LLVM does not put the globals of Rust in arena at this time. No other selftest is in Rust. Thus also remove the makefile rules that build Rust. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-2-alexei.starovoitov@gmail.com
7 daysselftests/bpf: Restore stack pointer subrange pruning coverageEduard Zingerman
After the clamping changes, r7 returns to the header with [-72, -16] instead of the narrower [-64, -16], so the test no longer checks subrange pruning. Assign an invariant fp-16 pointer to r7 in the loop, giving r7 an ANY SCEV that is not clamped and restoring strict-subrange coverage. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-11-f373aec9825f@gmail.com
7 daysselftests/bpf: 32-bit copy of the counter compared at the latchEduard Zingerman
When building SCEV expressions for the loop: w7 = w1; r7 = (zext32 r1) w1 = w7; r1 = (zext32 (zext32 r1)) w1 += 2; r1 = (zext32 (+ (zext32 (zext32 r1)) 2)) Computed SCEV expression for r1: (zext32 (linear r1 2)) Substituting this into r7's expression at the latch: (zext32 (zext32 (linear r1 2))) Without (zext32 (zext32 X)) -> (zext32 X) simplification rule the latch would not be recognized as linear and header_count won't be computed. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-10-f373aec9825f@gmail.com
7 daysselftests/bpf: Cases for SCEV interaction with infinite loop detectionEduard Zingerman
Add three test cases exercising state pruning after loop counter clamping. All turn a 32-bit stack spill into STACK_MISC during the first iteration. This prevents a state match at the outer loop header on the next iteration, while allowing states to match further inside the loop. All are falsely reported as infinite loop w/o changes in patch [1]. - clamp_callee_state_pruning(), a callee overwrites the upper half of the caller's stack slot. States then match at the callee's exit, where the current frame has no active loop. Verify that current_loop() finds the caller's active loop. - clamp_nested_loop_state_pruning(), the overwrite happens inside an inner loop. Exercise matching states when the inner loop is entered again on a subsequent outer iteration. - clamp_nested_unrolled_loop_state_pruning(), same as above, but the inner loop is not recognized by SCEV and is unrolled with a precise counter, so its entries are never marked terminating. [1] bpf: avoid false infinite loop reports after changes in SCEV clamping Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-9-f373aec9825f@gmail.com
7 daysselftests/bpf: Cases with empty range error under old clamping logicEduard Zingerman
A 64-bit and 32-bit examples leading to an empty register range error when scev.c:bpf_clamp_scev_regs() intersected current register state with computed iteration range: r1 = 0; verification r3 = 0; path loop: r3 += 1; | <---------. if r3 != 5 goto +0; | r3 ∈ {5} | r1 += 1; | | if r1 != 5 goto loop; '-----------' r0 = 0; exit; - At header r3 ∈ {0,1,2,3,4}. - After `if r3 != 5 goto ...` continued with r3 ∈ {5}. - On a second iteration bpf_clamp_scev_regs() computed: r3 := {0,1,2,3,4} ∩ {5} = ∅ And reported an error: verifier bug: scev clamp produced empty range for r3 Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-8-f373aec9825f@gmail.com
7 daysselftests/bpf: Pointer operands for 32-bit recurrences/latchesEduard Zingerman
Add four tests for pointer operands in 32-bit SCEV analysis. Check that loop bounds are not inferred for the following program shapes: 32-bit latch | 32-bit recurrence -------------------------+-------------------------- r6 = ... pointer ... | r6 = ... pointer ... r7 = ... pointer ... | r7 = ... pointer ... l: r6 += 1 | l: w6 += 1 ... | ... if w6 < w7 goto l | if r6 < r7 goto l Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-7-f373aec9825f@gmail.com
7 daysbpf: Print 32-bit SCEV bounds as 32-bit numbersEduard Zingerman
- Print large 32-bit bounds without sign extension. - Omit 32-bit bounds when they coincide with 64-bit bounds. Before: loop header at ..., widening r0 to 0x80000000..0xffffffff (s32 0xffffffff80000000..-1) step 1 loop header at ..., widening r0 to 0..3 (s32 0..3) step 1 After: loop header at ..., widening r0 to 0x80000000..0xffffffff (s32 0x80000000..-1) step 1 loop header at ..., widening r0 to 0..3 step 1 Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-6-f373aec9825f@gmail.com
7 daysbpf: Avoid false infinite loop reports after changes in SCEV clampingEduard Zingerman
Clamping now reproduces the widened range at every back edge, so induction variable ranges no longer vary between iterations. This can produce identical checkpoint states in terminating programs, for example: int main(...) { for (int i = 0; i < 10; i++) { foo(...); for (int j = 0; j < 3; j++) ...; } } void foo(...) { ...; } Handle two cases in states.c:bpf_is_state_visited(): - For checkpoints inside foo(), look for active loops in upper frames as well. Otherwise current_loop() returns NULL and an identical callee state can trigger an infinite loop report. - For checkpoints inside the inner loop, skip the infinite loop check when the current state is inside a terminating loop in any frame. That loop bounds how many times its body is re-executed, so an identical state on a later iteration does not imply nontermination. This covers the inner loop above, re-entered with a fresh entry state on each outer iteration, and inner loops SCEV cannot analyze. The nested_terminating_prune test still rejects such an outer loop, but now reaches the jump complexity limit instead of reporting an infinite loop. Update its expected message accordingly. Fixes: 6ccf49f79327 ("bpf: Use SCEV to widen bounded loops") Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-3-f373aec9825f@gmail.com
7 daysbpf: Do not intersect with current register range on clampEduard Zingerman
scev.c:bpf_clamp_scev_regs() is called each time verifier returns to a loop header via a backedge. It's purpose is to re-establish computed variable ranges for registers with linear SCEVs. It can be defined as: - For each register R with linear SCEV compute: - loop_range(R) := entry_range(R) * iterations_count - range(R) := range(R) ∩ loop_range(R) Such formulation is necessary to avoid ranges over-approximation in examples like below: r1 = 0; SCEVs: r1 = (linear r1 1) r3 = 0; r3 = (linear r3 1) loop: r3 += 1; r1 += 1; if r1 < 5 goto loop; r0 = 0; exit; - At loop entry r3 is widened to be in a range r3 ∈ {0,1,2,3,4}. - After increment it becomes r3 ∈ {1,2,3,4,5}. - On a second iteration the bpf_clamp_scev_regs() forces r3 to become r3 ∈ {1,2,3,4}. W/o clamping logic r3 range wouldn't shrink preventing loop from converging in states.c:states_equal(). However, intersection logic might lead to assigning an empty range to a register, as in example below: r1 = 0; verification r3 = 0; path loop: r3 += 1; | <---------. if r3 != 5 goto +0; | r3 ∈ {5} | r1 += 1; | | if r1 != 5 goto loop; '-----------' r0 = 0; exit; - At header r3 ∈ {0,1,2,3,4}. - While exploring the branch `if r3 != 5 goto ...` with r3 ∈ {5}. - On a second iteration: r3 := {0,1,2,3,4} ∩ {5} = ∅ Which stops verification with the following error: verifier bug: scev clamp produced empty range for r3 Technically this means that the current verification path is impossible at runtime and should not be traced further. This commit mitigates the above by removing the intersection logic, the function is now defined as: - For each register R with linear SCEV compute: - range(R) := entry_range(R) * iterations_count This is still sound, provided that SCEV expressions loop execution counts are correct. Fixes: 6ccf49f79327 ("bpf: Use SCEV to widen bounded loops") Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026-scev-simpler-clamp-v2-2-f373aec9825f@gmail.com
8 daysselftests/bpf: Test missing and callback stack argumentsWeiming Shi
Exercise the path where a static seven-argument subprogram has unreliable BTF and is called through a bridge with only one initialized outgoing stack argument. The callee expects two stack arguments, but the unreliable-BTF path skips check_outgoing_stack_args(). Expect the verifier to reject the second r11 load at offset 16. Also exercise synchronous and asynchronous callbacks whose BTF prototypes declare a sixth argument. Initialize the outgoing slot at each helper call site so the programs reach the callback-specific rejection. Keep a valid six-argument direct call in each program so bpf_fixup_call_args() records the stack-argument requirement and cannot become an unrelated rejection fallback. The fix also rejects the existing uninitialized-stack-argument test before the later unreadable-register check. Update that test's expected diagnostic accordingly. Signed-off-by: Weiming Shi <bestswngs@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261026015250.1674676-2-bestswngs@gmail.com
9 daysselftests/bpf: Test borrowed iterator result lifetimesXu Yunxiang
Exercise borrowed VMA results before and after iterator advancement and destruction, including NULL next, trusted fields, and a FILE dynptr that must be discarded before advancing. Keep positive controls for using the current element and discarding the dynptr first. Use a test-module iterator returning current to verify the explicit independent-lifetime exception. Retain controls for RCU-protected results. Also check the generic trusted-field rule outside iterators: reading file->f_inode while holding an acquired file reference succeeds, but using the saved inode pointer after bpf_put_file() is rejected. The annotated programs check verifier loading and diagnostics; they do not request runtime execution of the added programs. Signed-off-by: Xu Yunxiang <xyx2021@mail.ustc.edu.cn> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Amery Hung <ameryhung@gmail.com> Link: https://patch.msgid.link/20261024100647.2579244-3-xyx2021@mail.ustc.edu.cn
10 daysselftests/bpf: Test bpf_send_signal_task() from kernel thread contextAditya Sharma
The existing send_signal tests, including the _remote variants that exercise bpf_send_signal_task() with a caller-supplied target, all gate on if ((bpf_get_current_pid_tgid() >> 32) == pid) so the BPF program only ever runs while current is the test process. The caller-context dimension is therefore untested, which is how bpf_send_signal_task() failing from kernel thread context went unnoticed. Add a program attached to tp_btf/workqueue_execute_start, where current is always a kworker. It cannot filter on current, so it is driven by target_pid and gated on a kworker_test flag that only this test sets, and the test asserts the child receives the signal. Setting pid to 0 leaves the pre-existing programs in the skeleton inert. Workqueues run on their own, so nothing has to be triggered from userspace. Without removing the nmi_uaccess_okay() check, this test fails on x86. Signed-off-by: Aditya Sharma <adi.sharma@zohomail.in> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261001072449.1377267-3-adi.sharma@zohomail.in
10 daysselftests/bpf: Test JIT jumps which change at a repeated image lengthMykyta Yatsenko
Cover the case where two JIT passes give the same image length while jumps still change size, which used to fail with -ENOTSUPP on x86-64. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://patch.msgid.link/20261022-jit_size_fix-v2-2-4bee6921b218@meta.com
10 daysselftests/bpf: Wait for the struct_ops map to be freed in assoc_in_timerQiliang Yuan
st_ops_assoc_in_timer_no_uref runs .test_1, which starts a timer to call it again 500ms later, drops every reference to the struct_ops map, and expects the timer callback to find no struct_ops associated with its program anymore. The association goes away only when the last reference to the map is dropped. syscall_prog holds one through its own association and drops it only when it is freed, in a work item after an RCU tasks trace grace period. With other tests running in parallel, that can take longer than 500ms, and the callback still reaches the struct_ops and gets MAP_MAGIC instead of -1. Have the timer callback restart the timer until the map is gone, as it does for st_ops_assoc_in_timer_free. Calling the struct_ops through the association until then is safe, as the map is freed only after a grace period that follows clearing the association. st_ops_assoc_in_timer_no_uref run 100 times with test_progs -j32 running in the background, on a KASAN kernel with the fix, x86_64 VM with 32 vCPUs, before and after this patch: before after outcome 2 of 100 failed (MAP_MAGIC) 0 of 100 failed (MAP_MAGIC) Fixes: 0e841d19263a ("selftests/bpf: Test getting associated struct_ops in timer callback") Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261022-selftests-bpf-struct-ops-assoc-timer-v6-4-2c0f18e82582@gmail.com
10 daysselftests/bpf: Test freeing a struct_ops map under a running progQiliang Yuan
st_ops_assoc_in_timer_no_uref drops every reference to the struct_ops map while a timer callback of its prog calls .test_1 through the association, and checks that the callback ends up with no struct_ops. The timer first fires 500ms later and .test_1 returns right away, so the callback hardly ever runs .test_1 while the map is freed, and the test can't catch a map that is freed under a running .test_1. Add st_ops_assoc_in_timer_free, which starts the timer right away, restarts it with no delay until the association is gone, and makes .test_1 spin in bpf_loop() when the timer callback calls it. Share the steps of st_ops_assoc_in_timer_no_uref with it through a helper, which stops when associating or running syscall_prog fails instead of waiting for a timer that never starts. st_ops_assoc_in_timer_free run in a loop on kernels of the same bpf-next commit with KASAN enabled, x86_64 VM with 32 vCPUs, without and with the previous fix: without the fix with the fix outcome Oops (int3) on run 1 100 of 100 passed, median 0.28 s Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261022-selftests-bpf-struct-ops-assoc-timer-v6-3-2c0f18e82582@gmail.com
11 daysMerge tag 'bpf-next-7.4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next Pull bpf updates from Alexei Starovoitov: "Major changes: - Introduce scalar evolution (SCEV) analysis in the verifier. It infers how registers and stack slots change in a loop and lets the verifier check bounded loops with induction variables as ranges instead of walking every iteration. The number of processed insns drops ten fold in programs with loops (Eduard Zingerman) - Add 'callx' instruction: indirect call of a static BPF subprogram. The address is taken with ld_imm64 or loaded from read-only data. Supported by x86-64, arm64 and riscv64 JITs (Alexei Starovoitov, Pu Lehui) - Add unwind_goto and unwind_exit instructions, so that Rust panic or C++ exception can run destructors of every frame it passes through. The normal path is free of unwind code. Supported by x86-64 and arm64 JITs (Alexei Starovoitov) - Support programs compiled by rust-bpf: treat load and store through a number as arena access with BPF_F_ARENA_SCALAR, accept rust names in BTF (Alexei Starovoitov) - Raise BPF program stack size from 512 bytes to 2 KiB on x86-64 and arm64 (Kumar Kartikeya Dwivedi) - Support struct, union and __int128 up to 16 bytes passed and returned by value in BPF subprograms and kfuncs, and fix x86-64 and arm64 trampolines for such arguments (Yonghong Song) - Introduce a common way to attach struct_ops to a cgroup via bpf_link. bpf_tcp_ops is the first user and mirrors TCP sock_ops callbacks (Martin KaFai Lau, Amery Hung) - Describe inlined functions in BTF. New kinds tell where the inline sites are and how to fetch the arguments there. CONFIG_DEBUG_INFO_BTF_INLINE keeps it apart from the main BTF in .BTF.inline section or in btf_vmlinux_inline.ko (Alan Maguire) - Fix many memory safety, lifetime and locking bugs in BPF core, verifier, iterators, local storage, dynptr, devmap, cpumap and seg6local (Josef Bacik, Alexei Starovoitov) - Diff stat is dominated by selftests and by removal of lib/test_bpf.c. Its 16k lines of instruction tests were converted to BPF selftests that BPF CI runs on every architecture it covers (Daniel Borkmann) Other features and fixes: - Add KASAN checks to memory accesses of JITed programs on x86-64 (Alexis Lothoré) - Complete unification of helper, kfunc and subprog argument checks in the verifier (Amery Hung) - Add bpf_copy_from_user_mm[_str]() kfuncs (Anastasios Papagiannis) - Various features and fixes (Daniel Borkmann): - Add .bpf keyring for program signature verification, modelled after dm-verity keyring, and support ML-DSA in signing tools - Emit shorter and faster code in x86-64 JIT for patterns that LLVM generates - Fix various issues in gotox handling - Let BPF LSM set xattrs at inode creation with bpf_inode_init_xattr() (David Windsor, Daniel Borkmann) - Use sleepable page allocation in sleepable arena paths. Fix races between arena free, allocation and user page fault (Emil Tsalapatis) - Switch BPF crypto from lskcipher to AES-CBC and AES-ECB libraries (Eric Biggers) - Add bpf_proactive_reclaim() kfunc (Hui Zhu) - Render decl_tags in libbpf btf_dump and add tests for bpftool C dump (Ihor Solodrai) - Speed up tracing_multi attach on x86 (Jiri Olsa) - Various features and fixes (Kumar Kartikeya Dwivedi): - Add BPF_PROG_STREAM_OPEN command to read BPF streams through a file descriptor with poll support - Let kernel structs publish arena pointers with __arena type tag - Fix __uninit kfunc output buffers and fastcall rewrite with indirect stack accesses - Refuse CO-RE relocations for signed programs - Add enqueue_rcvq and dequeue_rcvq hooks to bpf_tcp_ops to adjust sk_rcvlowat and avoid unnecessary wakeups (Kuniyuki Iwashima) - Add bpf_ksock_sendto() kfunc and allow ksock connect and send from bpf_wq (Mahe Tardy) - Fix racy plt target update in arm64 bpf_arch_text_poke() (Matthew Wood) - Restructure BPF selftests Makefile as a layered build (Mykola Lysenko) - Speed up hash map lookups for u32 and u64 keys (Mykyta Yatsenko) - Add signed div/mod, movsx, bswap and gotol to MIPS JITs, signed div/mod to parisc JITs (Nicholas Dudar, Johan Almbladh) - Fix stack overflow in build ID parser on 32-bit (Nickolai Zeldovich) - Add stack arguments, signed arena loads and gotox to riscv64 JIT. Pu Lehui is now co-maintainer of riscv BPF JITs (Pu Lehui, Chen Pei, Feng Jiang) - Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() kfuncs. Support fetching and/or/xor atomics in arena on x86-64 (Puranjay Mohan) - Fix flaky selftests, selftests with clang 23 and bpf-gcc (Qiliang Yuan, KaFai Wan, Vineet Gupta) - Fix builds broken by fatal resolve_btfids warnings, BTF generation on ARC, and define arch_cmpxchg_local() on arc, hexagon and openrisc (Sasha Levin) - Reduce memory use of hash maps by up to 50% per element (T.J. Mercier) - Mark pointer fields of sched_ext ops arguments as trusted (Tejun Heo) - Remove legacy bpf_asm, bpf_dbg and bpf_jit_disasm tools (Xia Yan) - Fix index overflow in queue and stack maps, arena range tree after allocation failure, tail call loop after freplace detach, lost signal in bpf_send_signal() (Yuan Chen) - Many more fixes and cleanups" * tag 'bpf-next-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (660 commits) selftests/bpf: Time tc_edt from its first packet with data selftests/bpf: Test unwind_exit of an exception callback selftests/bpf: Tests for 32-bit scalar evolution bounds computation bpf: Reject unwind_goto and unwind_exit in offloaded progs bpf: Support 32-bit linear scalar evolution bpf: Make unwind_exit of an exception callback exit in JITs selftests/bpf: Test forbidden bpf_ksock_sendto() LSM attach selftests/bpf: Test ksock sendto() bpf: Add bpf_ksock_sendto() kfunc selftests/bpf: Test unwinding from R0: R2 subprog selftests/bpf: Add a C++ prog with exceptions selftests/bpf: Add tests for unwind_goto and unwind_exit bpf, arm64: Support unwind_goto and unwind_exit bpf, x86: Support unwind_goto and unwind_exit bpf: Add unwind_goto and unwind_exit insns tools/bpf: Remove legacy BPF tools bpf: Annotate data races on bpf_lru_node type selftests/bpf: Add arena allocation race tests bpf: Fix arena race between page free and alloc leading to incoherency bpf: Revalidate faulted arena pages before installing user mappings ...
11 daysMerge tag 'net-next-7.4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next Pull networking updates from Paolo Abeni: "This includes a significant number of low-priority fixes - especially in the NIC drivers area - that we deferred from the last few RCs in the previous cycle, which can't be easily outlined in the synopsis below. Core & protocols: - Continue the work on removing rtnl_lock dependencies: - per-netns ARP and ND neighbour tables, with the default settings now configurable per netns (inheritance from init_net is controlled by the new net.core.neigh_inherit_init_net sysctl) - RCU-protected configuration and rtnl_lock-less fill_info() for hsr, netkit, sit, vlan and vxlan devices - per-netns device unregistration for ip tunnel and gre devices - use the netdev instance lock instead of rtnl_lock when reading speed and duplex via sysfs - batch the flushing of uncached routes at device unregistration time, relieving rtnl_lock contention on netns dismantle. - Add hardware pacing offload support, admin-controlled via a new rtnetlink attribute, with sch_fq integration (implemented in idpf). - Re-segment BIG TCP GSO packets into GSO packets fitting the egress device limits instead of plain MSS-sized segments, improving throughput for mixed BIG TCP / non-BIG TCP paths by up to 70%. - Generate RSS keys that spread flows over all the RX queues; the previous random keys could leave some queues unused. - Optimize the bridge VLAN forwarding paths: cache the port-VLAN in fdb entries and consider only VLAN members when flooding, for ~10% more Mpps in the fdb forwarding path. - A few TCP/IP performance improvements aimed at efficient cache usage and reducing contention. - Add the TCP ROCCET congestion control, a CUBIC variant aimed at avoiding bufferbloat in cellular networks. - Continue the conversion of getsockopt callbacks to sockopt_t. - Add an ethtool command to list the front-facing ports of an interface, including SFP cages and modules, using the phy_port representation. - Enable BIG TCP support for bareudp tunnels. - Remove the IPV6_ADDRFORM socket option and disallow buggy TCP state transitions (listen() + shutdown() + connect() and connect() + connect(AF_UNSPEC) + listen()). - Remove most BUG_ON()s from core packet processing, replacing them with error paths. Wireless: - Latency improvements, including lockless station get/dump and beacon updates, plus RTNL reduction and locking cleanups. - Infrastructure for non-station TX/RX with MLO. - NAN (Wi-Fi Aware) Instant Communication support and other NAN improvements. - Control frame Integrity Protocol (CIP) and protected TWT support. - Improvements for AP regulatory checks. Netfilter: - Disable br_netfilter in user namespaces and schedule it for removal in 2027. - Restrict the raw table in nft_compat to the specific family, hook and priority. - Prepare the flowtable for mixed IPv4-over-IPv6 tunneling (and vice versa). - Use GFP_KERNEL_ACCOUNT for most netfilter allocations, for better integration with memcg. - Allow discovering conntrack zone filtering support in ctnetlink dumps, and fix nfnetlink_hook handling of large dumps. Deletions: - Move the LLC type 2 sockets out of tree. There are no known users and the code attracts a never-ending stream of LLM-driven fixes. Device drivers: - New drivers: - Meta Platforms NIC (mpnic), the second-generation NIC from Meta - initial skeleton of the Nebula-matrix NICs driver (nbl) - X-Powers AC200/AC300 Fast Ethernet PHYs - Ethernet high-speed NICs: - Intel: - i40e: XDP metadata support for RX hash and VLAN tag - ice: expose the E825 TSPLL state via the DPLL subsystem - nVidia/Mellanox: - move the data direct infrastructure from IB to core, in preparation for netdev support. - reduce the memory used per offloaded TC rule - Meta (fbnic): - support large io_uring zero-copy RX buffers - Microsoft vNIC (mana): - add BQL support - Ethernet NICs consumer, and embedded: - Airoha: - LRO offload support - Cadence (macb): - context swapping for ringparam and MTU changes, avoiding buffer loss under memory pressure - Mucse (rnpgbe): - TX/RX and link status support - NXP (enetc): - SR-IOV improvements and VF support for ENETC v4 - Qualcomm (ppe): - IPQ5424 support - Realtek PCI (r8169): - phylink support - RSS support for RTL8127 - Renesas (ravb): - gPTP support for R-Car Gen4 - Synopsys (stmmac): - XDP multi-buffer support on the TX side - tc mqprio hw queue priority offload - support for RK3568 SGMII, Allwinner H616 EMAC1, UltraRISC DP1000 and Qualcomm sa8255p - Ethernet switches: - Mediatek (mt7530): - fast age and change conduit support - Microchip (ksz): - support for KSZ8995XA/KS8995XA - Microchip (lan966x): - PCIe FDMA support, ~20x throughput increase in PCIe endpoint - Microchip (sparx5): - Time Aware Shaper (taprio) offload - Motorcomm (yt921x): - LED and SerDes PCS support - Realtek (rtl8365mb): - EEE support - Ethernet PHYs: - Broadcom: - enable jumbo frames on BCM54xx - Realtek: - support for RTL8261CE_CG and RTL8261D_VM - MDIO support for RTL838x and RTL839x - WiFi drivers: - Broadcom (brcmfmac): - FT/OKC roaming offload - Intel (iwlwifi): - UHR sniffer support - support for newer UEFI/BIOS tables - MediaTek (mt76): - mt7925 NAN improvements - offchannel/scan improvements and MLO fixes - Morse Micro (mm81x): - monitor mode support - Qualcomm (ath12k): - IPQ5332 platform infrastructure - Realtek (rtw88): - RTL8723BS support - SDIO TX performance improvements - Realtek (rtw89): - P2P_DEVICE support - BT-coex updates for RTL8922D - Bluetooth: - move H:4 reassembly into the Bluetooth core - add generic support for vendor packets - MGMT: add security level changed event - Bluetooth drivers: - btusb: support Bulk Serialization Mode - Intel: support Draco and Titan Lake, allow unsigned firmware - Mediatek: MT7928 support - Qualcomm: QCC2072 support - Broadcom: Synaptics 4384 support" * tag 'net-next-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2126 commits) Bluetooth: btusb: disable by default Qualcomm multi-subsystem tipc: fix broadcast sender hang on last acker departure tipc: fix use-after-free of broadcast reception link at node release r8169: clear TX LPI on RTL8168h at link up after phylink conversion tun: Require CAP_NET_ADMIN to attach to an ownerless device net/sched/sch_cake: drop dead nla_nest_end() error check net/sched/sch_cake: widen buffer_used to u64 net/sched/sch_cake: reduce parent backlog when clearing a tin net/sched/sch_cake: serialize reconfiguration with the datapath tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table net/mlx5e: Stop asserting for RTNL when closing channels net: shrink the payload-only part of skb dataref to one bit net: wwan: iosm: validate msg_head before indexing msg_ring net: bgmac: rate limit RX error messages selftests: net: veth: test XDP_TX to a peer with GRO enabled veth: schedule the peer's NAPI after XDP_TX when only GRO is enabled pppoe: delete session hash entries by pointer match net: lan969x: don't disable hardirqs in fdma tx clear net: sparx5/lan969x: do not clobber the PSFP cycle timer update period net: lan969x: fix DSM calendar for empty taxis ...
13 daysMerge tag 'rcu.2026.10.12b' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux Pull RCU updates from Paul McKenney: "Execution contexts and call_rcu() and call_srcu(): - Make call_rcu() and call_srcu invocable from NMI handlers and while holding scheduler locks (using irq-work handlers) - Add rcutorture and BPF tests calling these functions from these contexts - Disable rcutorture overload testing for RCU readers that are "fragile", that is, that do not either disable preemption or have some form of RCU priority boosting SRCU updates: - Add an atomic SRCU where readers run with preemption disabled and grace periods can be invoked from atomic contexts. David Woodhouse has a patch series exploiting this for GPC - Add torture and lockdep tests for atomic SRCU - Add numerous optimizations for atomic SRCU based on the fact that it does not have callbacks, for example, eliminating any transition to "big" srcu_struct structures even on systems that configure these to happen at initialization time Additional torture-test updates: - Fix a divide-by-zero bug in forward-progress testing - Synchronously wait for all IRQ-queued callbacks to complete - Allow alternative "ssh" commands to be specified for use by kvm-remote.sh - Fix kvm-again.sh re-run failure on PowerPC - Add additional lockdep testing for atomic SRCU - Fix error double-counting in srcu_lockdep.sh - Add atomic SRCU cross-CPU IRQ context mismatch testing, with the - trick being that the atomic SRCU readers context must be at least as strict as that of the atomic SRCU grace-period wait. So for example, if the readers have IRQs disabled, so must the grace-period wait Miscellaneous updates: - Update stallwarn.rst documentation for the re-implementation of RCU Tasks Trace in terms of SRCU - Fix the lazy-callback shrink scanner budget computation so that it honors the reclaim budget - Avoid panicking on RCU CPU stalls that end before the warning can be printed - Add "running" and "boosted" indications to the RCU task stall warning output - People have been (incorrectly) relying on rcu_barrier() to wait for kfree_rcu() callbacks and processing. But it turns out to be easier to fix rcu_barrier() to meet their expectations than to fix their code to live within the earlier rcu_barrier() specification. So rcu_barrier() now waits on kfree_rcu() callbacks and processing - Disable RCU Tasks console output that track when this RCU flavor switches between per-CPU and global callback queuing. New use cases appeared that generated enough console traffic to cause trouble, and no one seemed to care about these messages. For those needing those messages, there is a new rcupdate.rcu_task_collapse_debug kernel boot parameter - Fix __rcu pointer attribute handling to eliminate false positives - Fix typos and drop redundant #include directives" * tag 'rcu.2026.10.12b' of git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux: (46 commits) rcutorture: Add atomic SRCU cross-CPU IRQ context mismatch test selftests/rcutorture: Fix double nerrs count in srcu_lockdep.sh selftests/rcutorture: Wire atomic SRCU into srcu_lockdep.sh rcutorture: Add atomic SRCU lockdep support rcutorture: Fix kvm-again.sh re-run failure on ppc64 torture: Allow specifying alternative ssh command to kvm-remote.sh rcutorture: Synchronously wait for all rcu_torture_irq() callbacks to complete rcutorture: Fix divide-by-zero with fwd_progress_div=1 srcutree: Preserve IRQ state in synchronize_srcu_atomic() callchain srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic() srcutree: Add lockdep and early-boot checks to synchronize_srcu_atomic() srcutree: Skip torture to-big transition for atomic SRCU srcutree: Don't transition atomic SRCU to big in srcu_gp_end() srcutree: Make init_srcu_struct_atomic() prevent transition to big srcu: Restrict atomic-SRCU non_block annotation to task context srcutree: Remove srcu_barrier() sleep for atomic SRCU srcutree: Skip callback scheduling for atomic SRCU grace periods srcutree: Add reader-free fastpath to synchronize_srcu_atomic() rcutorture: Add atomic-SRCU support to torture.sh srcutree: Explicitly note DEFINE_SRCU() needs for srcu_barrier() ...
13 daysselftests/bpf: Time tc_edt from its first packet with dataQiliang Yuan
tc_edt sends 1MB over a TCP connection that a BPF program shapes with EDT, and checks that the rate it measures is within 2% of the target rate. The transfer takes about 200ms, so the margin is about 4ms. The measurement starts before send_recv_data(), which first creates the sender thread and accepts the connection. On a KASAN kernel, x86_64 VM with 32 vCPUs, that takes 0.7ms when idle and up to 4.7ms with all CPUs busy, while the BPF program spreads the data over 200.08ms in the median. The test also fails without test_progs -j where everything runs slower, e.g. on s390x and with ASAN in BPF CI. Have the BPF program note when the first packet with data goes out, and start the measurement there. tc_edt run 100 times on the same VM, idle and with 32 busy loops in the background, before and after this patch: before after idle 0 of 100 failed 0 of 100 failed busy loops 3 of 100 failed 0 of 100 failed Fixes: b0f82e7ab6fb ("selftests/bpf: integrate test_tc_edt into test_progs") Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com> Link: https://patch.msgid.link/20261019-selftests-bpf-tc-edt-serial-v2-1-41c3813e7916@gmail.com
13 daysselftests/bpf: Test unwind_exit of an exception callbackAlexei Starovoitov
In both tests the prog that throws returns to a call that unwind_goto follows, and its exception callback ends with unwind_exit: - An extension replaces a subprog that cannot unwind. unwind_goto after the call stays, since it shares the pad with a call of a subprog that can unwind. - A subprog that can unwind does a tail call. unwind_exit of the callback has to be exit. Without the fix the callers go to the pad and return 2 instead of 3 and 42 instead of 7. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020231942.2568163-4-alexei.starovoitov@gmail.com
13 daysselftests/bpf: Tests for 32-bit scalar evolution bounds computationEduard Zingerman
The post32_* tests exercise scev.c:compute_max_iters(): - 32-bit to 64-bit operand extension and overflow handling. - <, <=, >, >=, s<, s<=, s>, s>=, != operations. - Checks exact boundary hits and overflow at S32_MIN, S32_MAX, and U32_MAX. The post_cond_jne32* tests exercise zero-extension logic in scev.c:linear_bounds(): - 32-bit unsigned wraparound. - Entry and zero-extended iteration values disagreeing on base/step, requiring the step to be reduced. - Widened bounds containing both the original entry value and the zero-extended iteration values. - Preserving step and base when that union crosses the signed 64-bit boundary. The post_cond_alu{32,64}_jmp{64,32} tests cover mixed-width recurrences and comparisons: - Declining to compute an iteration count when operands or the predicted exit fall outside the required 32-bit ranges. - Computing iteration counts and widened bounds for compatible mixed-width loops. Also add a basic pre-condition loop test. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020-scev-32bit-v1-2-838f34f9f0cd@gmail.com
13 daysbpf: Support 32-bit linear scalar evolutionEduard Zingerman
Representation -------------- Represent ALU32 recurrences as: w0 += step -> (zext32 (linear r0 step)) Extend simplify() rules to maintain the above form for latch expressions. E.g. for a post-condition loop such as: w0 = 0; l: w0 += 1; if w0 != 3 goto l; exit; SCEV at header: (zext32 (linear r0 1)) Initial SCEV at latch: (zext32 (+ (zext32 (linear r0 1)) 1)) Simplified SCEV at latch: (zext32 (+ (zext32 (linear r0 1)) 1)) -> (zext32 (+ (linear r0 1) 1)) -> (zext32 (linear (+ r0 1) 1)) Iterations count computation ---------------------------- - Extract the main iteration-count logic from compute_max_iters() into compute_backedge_taken_count(). Reuse its 64-bit arithmetic after sign/zero extending the latch operands. - Reject the computed count if the predicted exit value falls outside signed/unsigned 32-bit range, e.g.: w0 = 0x7ffffffe; l: w0 += 1; if w0 s<= 0x7fffffff goto l; The 64-bit computation predicts an exit at S32_MAX + 1, but the 32-bit value wraps to S32_MIN and the comparison remains true. - Handle mixed 64-bit/32-bit comparisons/recurrences only when initial bounds and step fit in 32-bit ranges, e.g.: w0 = 0; r1 = 0x100000003 ll; l: w0 += 1; if r0 != r1 goto l; Truncating the bound to 32 bits would predict three header visits. However, `w0 += 1` keeps r0 within [0, U32_MAX], so it can never be equal to the 64-bit bound. Widened bounds computation -------------------------- - Update linear_bounds() to truncate the initially computed 64-bit range to 32 bits, then zero-extend it to obtain the 64-bit range of iteration values. Step computation needs to handle: - unsigned 32-bit wraparound; - entry and zero-extended iteration values disagreeing on base/step. - Union both ranges with the corresponding register ranges at entry, since the entry value need not be zero-extended. - Extend `struct bounds` to keep both {32,64}-bit ranges and pass both to bpf_set_reg_range(). A 64-bit range alone loses useful 32-bit information, e.g.: entry = 0, step = -1, two header visits r64: [0, U32_MAX] r32: [-1, 0] Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020-scev-32bit-v1-1-838f34f9f0cd@gmail.com
13 daysMerge tag 'lsm-pr-20261016' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm Pull lsm updates from Paul Moore: - Add LSM hooks, object blobs, and audit records for namespaces Add the necessary bits to enable LSMs to enforce access controls on the management of various kernel namespaces. While this pull request does not contain any in-tree users of these hooks, the Landlock pull request for Linux v7.4 will include Landlock support and the next merge window will likely include SELinux support as well. Considering the development behind these hooks, I expect that BPF LSM developers will also be making use of the namespace hooks, if they haven't already. - Update the inode LSM hooks to include mount idmaps This allows LSMs to incorporate the mount ID mapping into their access control decisions. While there are no current in-tree users of this, it was requested by those developing BPF LSM programs and this pull request includes a BPF LSM selftest. - Preserve the full 32-bit ioctl command in LSM audit records Previously only the low 16 bits were logged, ignoring the direction and size information in the upper 16 bits. The pull request also includes a Landlock based selftest to verify the full 32-bit ioctl value. - Ensure we don't call security_backing_file_free() multiple times Thankfully we don't have a problem with the current code base, but we want to fix this behavior now before it becomes a problem. - Clarify that only the current task may access current->cred The current code is a bit misleading around safely accessing the cred field in a task struct. Through comment and code corrections, this pull request clarifies that only the task itself may access its cred field. - Add SLAB_NO_MERGE to the credential object cache Harden the credential cache by ensuring credential objects live on dedicated slab pages. - Make use of safe memory zero'ing in the LSM Rust bindings - Update the docs for the current behavior of /sys/kernel/security/lsm - Update the docs for CONFIG_LSM and the "lsm=" command line option - Remove unnecessary code * tag 'lsm-pr-20261016' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: lsm: remove redundant NULL check in security_init() selftests/landlock: Check full ioctl commands in audit records lsm: Preserve full ioctl commands in audit records doc: fix LSM ordering description for /sys/kernel/security/lsm doc: describe CONFIG_LSM and lsm= as the selection mechanism selftests/bpf: verify mount idmaps reach inode hooks lsm: expose mount idmaps to inode hooks rust: lsm: replace `core::mem::zeroed` with `pin_init::zeroed` cred: prevent slab cache merging for cred_jar lsm: don't call security_backing_file_free() multiple times lsm: delete duplicate assignment in lsm_prepare() lsm: update the BUILD_BUG_ON() in audit_log_lsm_data() lsm: add LSM_AUDIT_DATA_NS for namespace audit records lsm: add LSM blob and hooks for namespaces ns: Free anonymous mount namespaces via ns_common_free() cred: clarify that task_struct::cred is only for the current task
13 daysMerge tag 'libcrypto-for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux Pull crypto library updates from Eric Biggers: - Migrate the x86 and riscv optimized implementations of various AES modes (ECB, CBC, CBC-CTS, CTR, XCTR, XTS) into lib/crypto/. This makes the library APIs be properly accelerated on these architectures, while still accelerating crypto_skcipher as well. It removes a lot of redundant glue code, since the crypto API boilerplate no longer needs to be duplicated for these architectures. It also fixes the longstanding issue where optimizations for these AES modes were disabled by default on these architectures. - Optimize AES-XTS on SPARC64 using the SPARC crypto opcodes - Move the SipHash code into lib/crypto/ - Update the ChaCha and Poly1305 functions to take size_t lengths, resolving issues where lengths over INT_MAX were mishandled - Make frame pointer unwinding work properly in some of the x86 assembly functions, by following the standard %rbp convention - Add helper functions for zeroizing structs - Make a few documentation improvements * tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: (49 commits) lib/crypto: md5: remove unused header lib/crypto: mips/chacha: Handle lengths of 2 GiB or more lib/crypto: arm/chacha: Handle lengths of 2 GiB or more in scalar code lib/crypto: chacha: Use size_t length lib/crypto: poly1305: Use size_t length lib/crypto: x86/sha512: Follow the normal %rbp convention lib/crypto: x86/sha256: Follow the normal %rbp convention lib/crypto: x86/sha1: Follow the normal %rbp convention lib/crypto: chacha20poly1305: zeroize state in __chacha20poly1305_decrypt lib/crypto: sparc/aes-xts: Add optimization using the AES opcodes lib: Move SipHash into lib/crypto/ lib/crypto: x86/aes-ctr: Remove some unreachable code crypto: x86/aesni-intel - Add transitional selections crypto: aes - Boost priority of encryption modes further lib/crypto: x86/aes: Set RNDKEY in aes_cbc_encrypt_aesni() lib/crypto: riscv/aes-xts: Migrate optimized code into library lib/crypto: riscv/aes-ctr: Migrate optimized code into library lib/crypto: riscv/aes-cbc: Migrate optimized code into library lib/crypto: riscv/aes-ecb: Migrate optimized code into library lib/crypto: riscv/aes: Pass key struct to assembly code ...
14 daysselftests/bpf: Test forbidden bpf_ksock_sendto() LSM attachMahe Tardy
Similarly to '7b0dfbf5776b ("selftests/bpf: Test forbidden bpf_ksock_send() LSM attach")', tests that the verifier filter prevents bpf_ksock_sendto() to be called in a LSM program attached to security_socket_sendmsg() as it would create a direct recursion. Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020155848.75711-4-mahe.tardy@gmail.com
14 daysselftests/bpf: Test ksock sendto()Mahe Tardy
These tests are covering that: 1. sendto() on a unconnected UDP socket works (and that the socket stays unconnected, i.e. send() on it fails with -EDESTADDRREQ). 2. sendto() on a connected UDP socket with a NULL address is equivalent to send(). 3. sendto() on a connected socket with an explicit address doesn't change the peer of the socket (send() after sendto() still sends to the original connected address). Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020155848.75711-3-mahe.tardy@gmail.com
14 daysselftests/bpf: Test unwinding from R0: R2 subprogKumar Kartikeya Dwivedi
Global subprograms returning a 16-byte scalar use R0:R2. The verifier therefore checks both registers at every ordinary and unwind exit. LLVM lowers a resume to "r0 = 0; unwind_exit". If cleanup code does not happen to initialize R2, the verifier rejects the unwind path with: R2 !read_ok Extend unwind_cxx with a global unsigned __int128-returning subprogram whose cleanup only releases its RCU read lock. Load it separately so the existing cases continue to run and the failure is attributed to this case. Check both the normal aggregate return and caught exception. The test passes once LLVM defines R2 before emitting unwind_exit. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020181320.1284798-7-alexei.starovoitov@gmail.com
14 daysselftests/bpf: Add a C++ prog with exceptionsAlexei Starovoitov
static __noinline int inner(int len) { rcu_guard guard; if (len > 100) throw 1; return len; } static __noinline int middle(int len) { preempt_guard guard; return inner(len) + 1; } SEC("tc") int catches(struct __sk_buff *skb) { try { return middle(skb->len); } catch (...) { return 42; } } The exception passes through two frames. The destructors call bpf_rcu_read_unlock() and bpf_preempt_enable(). The verifier insists on both, and the test checks that they ran in that order. In the second prog nobody catches. The destructors run and the prog returns 0. All that is left of the C++ runtime is four one line functions. __cxa_throw() calls _Unwind_RaiseException(), which llvm lowers. progs/*.cpp are built like progs/*.rs: by clang only and without skeletons. vmlinux.h and bpf_helpers.h are not C++, so the prog declares what it needs. clang that lowers unwinding [1] defines __BPF_FEATURE_UNWIND. Without it the object has no progs and the test is skipped. [1] https://github.com/llvm/llvm-project/pull/233649 Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020181320.1284798-6-alexei.starovoitov@gmail.com
14 daysselftests/bpf: Add tests for unwind_goto and unwind_exitAlexei Starovoitov
The tests spell the two insns out as raw insns, so they don't depend on llvm version. verifier_unwind: - A static subprog, a global one and a callee of callx leave either way at run time, through one and two frames. The verifier follows a static subprog, so the tests derive the argument from skb->len or read it from a map. - r0 of unwind_exit, r6-r9 and the stack are there in the pad. r1-r5 are not readable. - A pad is checked like any other code: it has to drop rcu_read_lock. - How the callee left is a part of the verifier state: two states that differ only in that are not pruned. - The pad of a call of a global subprog is always checked. - A callee that never returns, where unwind_goto stays and 'goto pc-1' follows it, and one that never unwinds, where it goes away with the pad. - What follows unwind_goto runs speculatively: with CAP_BPF only there is nospec in front of an insn that isn't safe with r0 of unwind_exit. - unwind_exit without unwind_goto after the call. - unwind_goto that doesn't follow a call of a subprog or is a jump target. - Reserved fields. - A sync callback cannot unwind. What it calls can. - unwind_exit of an async and of an exception callback is exit. - Tail call and ld_abs in a subprog that can unwind. - unwind_exit of the main prog is exit. - What x86-64 and arm64 JITs emit. With KASAN x86-64 JIT wraps a load in pushes, a call and pops, so the patterns start after the loads. - Private stack. On x86-64 r9 has to be restored on the way to the pad. The last one has to look at the return value of a prog that uses private stack. raw_tp is such a prog. Its test_run doesn't take a packet, so let test_loader run it like it runs syscall progs. unwind_attach, with the caller run after every attach: - fentry on a subprog that unwinds. fexit is refused. - freplace of a subprog that unwinds by an extension that returns and by one that unwinds. The caller goes on after the call or in the pad. - An extension that unwinds cannot replace a subprog that doesn't. Every check that the series adds was removed in turn to see that a test fails. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261020181320.1284798-5-alexei.starovoitov@gmail.com
2026-10-20selftests/bpf: Add arena allocation race testsEmil Tsalapatis
Add selftests for races between arena frees, reallocation and user faults: - realloc_during_free, realloc_during_deferred_free: a synchronous or deferred free keeps its range allocated until it completes. - fault_free_realloc: user and BPF views of a page stay coherent while it is repeatedly faulted, freed and reallocated. Pause frees in zap_vma_range(), after the range's kernel mappings are gone. Unlike flush_tlb_kernel_range(), which is inline on arm64, it is generic MM code that fentry can attach to. Map the page into user space first, so that the free has to zap it. Print why a subtest is skipped when a tracing target is missing. The reader in fault_free_realloc skips reads that raise SIGBUS, which a fault on a page that is being freed does. Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019201108.4552-4-emil@etsalapatis.com
2026-10-20selftests/bpf: Test that a signed program with CO-RE relocations is refusedKumar Kartikeya Dwivedi
Load a two insn program with a junk signature and one CO-RE relocation record, and check that the kernel refuses it with -EACCES and the message naming the relocations, before it examines the signature. Without the check the same load gets as far as the signature and fails on it with -EBADMSG. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://patch.msgid.link/20261019144851.4052056-3-memxor@gmail.com
2026-10-19selftests/bpf: Test an arena kfunc argument passed from a subprogramKumar Kartikeya Dwivedi
Call a kfunc with an __arena argument from a global subprogram that does nothing else with the arena, the address arrives as a number and no cast is involved. The subprogram needs the arena base set up by its own prologue for the JIT to rebase the argument, which the BPF CI review found was not recorded for it. Pass a NULL constant to a nullable __arena kfunc argument as well, from a program that touches the arena nowhere else. The verifier takes its early exit for a NULL argument, but the JIT rebases the call like any other, behind the NULL test the function model asks for, so the arena base has to be set up for that call alone. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-17-memxor@gmail.com
2026-10-19selftests/bpf: Test the address space rendering of the arena type tagKumar Kartikeya Dwivedi
Add an arena-tagged pointer member to the type tag dump test and expect the address space attribute in front of the tag. The struct_ops test that mirrors the previous rendering now describes it as the output of an older libbpf. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-16-memxor@gmail.com
2026-10-19selftests/bpf: Test arena binding by libbpfKumar Kartikeya Dwivedi
Attach a struct_ops callback with an __arena argument from an object whose callback and unrelated program never refer to the arena, drive it through the kernel, and check that an unrelated program of the object got the arena among its maps as well. Load the same object through bpf_object__prepare() and bpf_program__clone() too, the way veristat loads programs. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-13-memxor@gmail.com
2026-10-19selftests/bpf: Move the no-arena tests out of objects with an arena mapKumar Kartikeya Dwivedi
Two programs expect to fail for want of an arena while living next to an arena map: the kfunc argument case in arena_kfunc.c and the scalar access case in verifier_arena_scalar.c. Once libbpf binds the arena of an object to every program in it, they would load. Move them to an object without an arena map ahead of that change, where the kernel checks still apply, so that the tests pass at every step. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-11-memxor@gmail.com
2026-10-19selftests/bpf: Test __arena pointer membersKumar Kartikeya Dwivedi
Add a struct_ops member to bpf_testmod whose argument struct publishes arena pointers: a plain one, a __nullable one that is left NULL, one behind a nested struct, one inside a union, next to a scalar, together with a kfunc that fills the struct with the kernel address of an __arena argument and calls the member. Two callbacks read the pointers back. One shares the header with the module, so the members are arena pointers on the program side as well and need no cast; it also records the register a load produces, which must be the arena offset with the upper 32 bits clear, reads the member with a load-acquire as well, which has to yield the same pointer, and hands the pointer to an __arena kfunc. The other mirrors the vmlinux.h rendering of the struct, a kernel pointer with the type tag as an attribute, and casts the members to the arena address space the way a program built against vmlinux.h has to. Both increment the value through each pointer and the trigger checks the count. The first callback also reads a member through a plain pointer to a bad address, a probed load that is skipped or faults, and checks that it reads as NULL rather than as an arena pointer. The failure cases cover a store to the member, which a struct_ops program cannot do to any argument member, a load from the union, an exchange, one insn loading the arena pointer on one path and a scalar or a memory pointer on another, and a program without an arena. On a kernel whose module BTF carries no type tags the member tests are reported as skipped. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-10-memxor@gmail.com
2026-10-19selftests/bpf: Test __nullable pointer membersKumar Kartikeya Dwivedi
Add a struct_ops member to bpf_testmod whose argument struct carries two task pointers, one plain and one __nullable, both made trusted through a __safe_trusted alias of the struct in the module BTF, and a kfunc that calls the member once with the nullable pointer unset and once set. The callback acquires the plain pointer as is and the nullable one only after a check, driven through the kfunc from a syscall program. The failure case passes the nullable pointer to bpf_task_acquire() unchecked and is rejected as possibly NULL. More members cover the other kinds of pointer: a per-CPU one, which only the per-CPU helpers consume and which keeps the flag, the struct itself through a plain pointer and through an untrusted one out of a __kptr_untrusted map value that is never set, and a pointer to a scalar, which are probed and lose it. The callback uses each after a check; a failure test passes the per-CPU pointer unchecked, and three programs read the probed ones unchecked and load. bpf_testmod_ops3 gets the base helpers for the per-CPU helpers. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-9-memxor@gmail.com
2026-10-19selftests/bpf: Clone a program that calls a module kfuncKumar Kartikeya Dwivedi
Prepare an object whose program calls a kfunc of bpf_testmod and load the program through bpf_program__clone(), the way veristat loads programs. The module BTF fd sits in slot 1 of the fd_array of the object and slot 0 is empty; the clone used to pass the fill index of that array as fd_array_cnt, which made the kernel resolve slot 0 and fail the load with "fd 0 is not pointing to valid bpf_map or btf". Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019132203.3034698-5-memxor@gmail.com