<feed xmlns='http://www.w3.org/2005/Atom'>
<title>laptop-kernel/tools/testing/selftests/bpf, branch master</title>
<subtitle>Linux kernel tree for laptop</subtitle>
<id>https://git.zx2c4.com/laptop-kernel/atom/tools/testing/selftests/bpf?h=master</id>
<link rel='self' href='https://git.zx2c4.com/laptop-kernel/atom/tools/testing/selftests/bpf?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/'/>
<updated>2026-10-01T16:40:05Z</updated>
<entry>
<title>selftests/bpf: Add a test for objects stuck in free_by_rcu_ttrace</title>
<updated>2026-10-01T16:40:05Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@kernel.org</email>
</author>
<published>2026-09-30T09:59:20Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=aeb709c767aeca996e6011133e4f7bdb2a4af652'/>
<id>urn:sha1:aeb709c767aeca996e6011133e4f7bdb2a4af652</id>
<content type='text'>
Delete all elements of BPF_F_NO_PREALLOC hash map in one batch. The first
free_bulk() starts RCU tasks trace GP and the rest of the elements are
freed while it's in flight. Wait for call_rcu_ttrace_in_progress to clear
in bpf_mem_cache of every cpu and check that free_by_rcu_ttrace and
waiting_for_gp_ttrace lists are empty.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20260930095920.601738-4-alexei.starovoitov@gmail.com
Signed-off-by: Kumar Kartikeya Dwivedi &lt;memxor@gmail.com&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Test packet range of pointers sharing an id</title>
<updated>2026-10-01T16:39:27Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@kernel.org</email>
</author>
<published>2026-10-01T14:52:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=33a154a96e71a34a1bcca9f40da343dbbf7b38b4'/>
<id>urn:sha1:33a154a96e71a34a1bcca9f40da343dbbf7b38b4</id>
<content type='text'>
Add tests where two packet pointers share an id and tightening one
pointer's umax from its var_off would put it less than their constant
distance from the other's umax: with an index &amp; 0x38 capped at 50, the
base pointer keeps umax 50, so the pointer 8 bytes further on must keep
umax 58, even though its known bits allow at most 56.

These refused a valid program or accepted an out-of-bounds access before
the fix:

- check the advanced copy, load through the base: valid, was refused;
- check the base, load the byte at base + 1 through a copy advanced by
  8: was accepted;
- check base + 4, load 4 bytes at base + 2 through base + 8: reads two
  bytes past the checked range, was accepted;
- the same as the second with data_meta pointers checked against data:
  was accepted.

These pass with and without the fix and cover nearby paths:

- subtract an unknown scalar from a checked pointer and load below it
  (the range is kept across a new id);
- reach a load through two paths whose checks cover 8 and 7 bytes after
  the loaded pointer; the second path must not be pruned by the first;
- spill a copy of a pointer, check the pointer, fill the copy and load
  one byte past the checked range: the load is refused, and the copy
  has the range of the check.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20261001145255.855630-2-alexei.starovoitov@gmail.com
Signed-off-by: Kumar Kartikeya Dwivedi &lt;memxor@gmail.com&gt;
</content>
</entry>
<entry>
<title>bpf: Fix packet range of pointers sharing an id</title>
<updated>2026-10-01T16:39:27Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@kernel.org</email>
</author>
<published>2026-10-01T14:52:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=b88822d2584f78cbdad1d8256510dcac108b5630'/>
<id>urn:sha1:b88822d2584f78cbdad1d8256510dcac108b5630</id>
<content type='text'>
Since commit 022ac0750883 ("bpf: use reg-&gt;var_off instead of reg-&gt;off
for pointers"), find_good_pkt_pointers() sets the range of all packet
pointers sharing an id from the umax of the compared pointer, and
check_packet_access() requires umax + off + size &lt;= range.  That assumes
the umax of two such pointers differ by exactly their constant distance.
reg_bounds_sync() breaks it when var_off tightens one umax and not the
other:

	r4 &amp;= 0x38
	if r4 &gt; 50 goto exit     ; umax 50, var_off (0x0; 0x38)
	r5 = pkt + r4            ; umax 50
	r6 = r5
	r6 += 8                  ; umax 56, not 58

Comparing r6 with pkt_end sets the range to 56, and the valid 8-byte
load at r5 is rejected (50 + 8 &gt; 56).  Comparing r5 sets it to 50, and
the out-of-bounds 1-byte load at r6 - 7, i.e. r5 + 1, is accepted
(56 - 7 + 1 &lt;= 50).

Don't call reg_bounds_sync() on a packet pointer that keeps its id (a
constant was added or subtracted) or its range (an unknown non-negative
value was subtracted), so that var_off cannot tighten its umax.  Only
update the 32-bit bounds from var_off: reg_bounds_sanity_check() wants
them constant when the lower half of var_off is, e.g. for pkt + 8.

This relies on nothing else changing the 64-bit bounds of a packet
pointer, which holds today.

var_off of such a pointer is no longer narrowed by its bounds.  Adjust
three verifier_align expectations; the low bits, which the alignment
checks use, don't change.  veristat on the selftests shows no verdict
changes and +0.8% insns in test_cls_redirect_subprogs.

Fixes: 022ac0750883 ("bpf: use reg-&gt;var_off instead of reg-&gt;off for pointers")
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20261001145255.855630-1-alexei.starovoitov@gmail.com
Signed-off-by: Kumar Kartikeya Dwivedi &lt;memxor@gmail.com&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Detach a trampoline prog while a task sleeps before it</title>
<updated>2026-09-29T05:54:16Z</updated>
<author>
<name>Florent Revest (Anthropic)</name>
<email>florent.revest@linux.dev</email>
</author>
<published>2026-09-26T13:56:00Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=d5288c519bbd0df9dff9f8dce2a8ce24e2ca9c8a'/>
<id>urn:sha1:d5288c519bbd0df9dff9f8dce2a8ce24e2ca9c8a</id>
<content type='text'>
Add a test for the use-after-free fixed by the previous commit. A
sleepable prog on bpf_fentry_test1() blocks a task on a userfaultfd
page, like bpf_mod_race does, while the two progs that run after it in
the same trampoline are detached and freed one after the other, which
the test knows from their .bss maps going away. After the first detach
the task is in an image that isn't the trampoline's current one
anymore. The task is then released and must not call into the freed
progs. This is done with fentry progs, with fexit progs, where the task
is already past the original function, and with a task sleeping in a
fentry prog while fexit progs are detached, where the original function
must still be called. bpf_mod_race's userfaultfd helper moves to
testing_helpers.c so that both tests can use it.

Without the fix, on a kernel with KASAN:

  BUG: KASAN: vmalloc-out-of-bounds in __bpf_prog_enter_recur+0xed/0x1e0
  Read of size 8 at addr ffa0000000144040 by task test_progs/171
  CPU: 6 UID: 0 PID: 171 Comm: test_progs Tainted: G           OE       7.2.0+ #1 PREEMPT(full)
  Call Trace:
   &lt;TASK&gt;
   __bpf_prog_enter_recur+0xed/0x1e0
   bpf_trampoline_6442545468+0x72/0xe3
   bpf_fentry_test1+0x9/0x20
   bpf_prog_test_run_tracing+0x183/0x3e0
   __sys_bpf+0xd3f/0x38f0
   ...

Signed-off-by: Florent Revest (Anthropic) &lt;florent.revest@linux.dev&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260926135605.1217928-4-florent.revest@linux.dev
</content>
</entry>
<entry>
<title>selftests/bpf: Test per-cpu initialization of a BPF_F_CPU created element</title>
<updated>2026-09-24T14:24:52Z</updated>
<author>
<name>Donggeun Yoo</name>
<email>donggeunyoo.kernel@gmail.com</email>
</author>
<published>2026-09-24T10:23:21Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=3422808f4e959266ea7790101ac90b8341f48226'/>
<id>urn:sha1:3422808f4e959266ea7790101ac90b8341f48226</id>
<content type='text'>
The existing cpu_flag subtests always prime a key with BPF_F_ALL_CPUS
before any BPF_F_CPU write, so the create path is never covered.

Add a subtest that creates the element with BPF_F_CPU on a map with
max_entries 1, so the key can only reuse the element the previous key
released, and check that the CPUs the update did not name read back
zero.  Run it for PERCPU_HASH preallocated and BPF_F_NO_PREALLOC,
whose per-cpu areas come from different allocators, and for
LRU_PERCPU_HASH.

Under BPF_F_NO_PREALLOC the reuse is only guaranteed on the cpu that
ran the delete, so pin the thread across the pair, and name a cpu other
than that one in map_flags.

Signed-off-by: Donggeun Yoo &lt;donggeunyoo.kernel@gmail.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260924102321.2120434-3-donggeunyoo.kernel@gmail.com
</content>
</entry>
<entry>
<title>selftests/bpf: Test for mixed arena/nonarena code paths</title>
<updated>2026-09-22T19:34:05Z</updated>
<author>
<name>Emil Tsalapatis</name>
<email>emil@etsalapatis.com</email>
</author>
<published>2026-09-22T17:20:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=a9e86dd9de4f933b69f5cca6293fd4c8919224ec'/>
<id>urn:sha1:a9e86dd9de4f933b69f5cca6293fd4c8919224ec</id>
<content type='text'>
Add a selftest to confirm the verifier rejects ALU operations
that return arena or non-arena results depending on code path.

Signed-off-by: Emil Tsalapatis &lt;emil@etsalapatis.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260922172028.6269-9-emil@etsalapatis.com
</content>
</entry>
<entry>
<title>selftests/bpf: Test rejection of pkt args to mutating subprogs</title>
<updated>2026-09-22T19:34:04Z</updated>
<author>
<name>Emil Tsalapatis</name>
<email>emil@etsalapatis.com</email>
</author>
<published>2026-09-22T17:20:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=1ed69a54d31848618131aaf3311a78adbe78ced0'/>
<id>urn:sha1:1ed69a54d31848618131aaf3311a78adbe78ced0</id>
<content type='text'>
Add a selftests that ensures that PTR_TO_PACKET arguments can
only be passed to subprogs that will never adjust the underlying
packet memory, and are rejected otherwise.

Signed-off-by: Emil Tsalapatis &lt;emil@etsalapatis.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260922172028.6269-7-emil@etsalapatis.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add selftests for rx_queue_mapping context access</title>
<updated>2026-09-22T19:34:04Z</updated>
<author>
<name>Emil Tsalapatis</name>
<email>emil@etsalapatis.com</email>
</author>
<published>2026-09-22T17:20:21Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=dec0c209a6808fe6de2e4787538e02786a16a4ef'/>
<id>urn:sha1:dec0c209a6808fe6de2e4787538e02786a16a4ef</id>
<content type='text'>
Add tests to ensure the verifier properly tracks the 0 bit state
and width of the rx_queue_mapping field read from struct sock.

Signed-off-by: Emil Tsalapatis &lt;emil@etsalapatis.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260922172028.6269-5-emil@etsalapatis.com
</content>
</entry>
<entry>
<title>selftests/bpf: Test dynptr slices past end of skb</title>
<updated>2026-09-22T19:34:04Z</updated>
<author>
<name>Emil Tsalapatis</name>
<email>emil@etsalapatis.com</email>
</author>
<published>2026-09-22T17:20:19Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=4fd72eb9f1c939ce33bb714c6f745a125ac5f40c'/>
<id>urn:sha1:4fd72eb9f1c939ce33bb714c6f745a125ac5f40c</id>
<content type='text'>
Add a selftest to ensure dynptr slices cannot include
past the end of the linear area of an skb.

Signed-off-by: Emil Tsalapatis &lt;emil@etsalapatis.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://patch.msgid.link/20260922172028.6269-3-emil@etsalapatis.com
</content>
</entry>
<entry>
<title>selftests/bpf: Reject iterator destruction through fp+0</title>
<updated>2026-09-21T22:00:59Z</updated>
<author>
<name>Xu Yunxiang</name>
<email>xyx2021@mail.ustc.edu.cn</email>
</author>
<published>2026-09-20T21:04:22Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=8244668cbbffc8e242b2c5204a2dea20bfca096c'/>
<id>urn:sha1:8244668cbbffc8e242b2c5204a2dea20bfca096c</id>
<content type='text'>
Add a verifier regression test that initializes a numeric iterator at fp-8
and attempts to destroy it through fp+0. The verifier must reject the
non-negative offset instead of treating it as the initialized stack slot.

Check the offset diagnostic to ensure rejection happens at the stack
object address check. The numeric iterator destroy operation is a no-op;
this test checks verifier rejection and does not run the program.

Signed-off-by: Xu Yunxiang &lt;xyx2021@mail.ustc.edu.cn&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Reviewed-by: Sun Jian &lt;sun.jian.kdev@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20260920210423.345636-3-xyx2021@mail.ustc.edu.cn
</content>
</entry>
</feed>
