<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/tools/testing/selftests/bpf/prog_tests/percpu_array_inner_map.c, branch stable</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/tools/testing/selftests/bpf/prog_tests/percpu_array_inner_map.c?h=stable</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/tools/testing/selftests/bpf/prog_tests/percpu_array_inner_map.c?h=stable'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2026-05-14T15:18:50Z</updated>
<entry>
<title>bpf: Use array_map_meta_equal for percpu array inner map replacement</title>
<updated>2026-05-14T15:18:50Z</updated>
<author>
<name>Guannan Wang</name>
<email>wgnbuaa@gmail.com</email>
</author>
<published>2026-05-14T07:44:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=593980175389a05793f6060aa20e626330960395'/>
<id>urn:sha1:593980175389a05793f6060aa20e626330960395</id>
<content type='text'>
percpu_array_map_ops.map_meta_equal points to the generic
bpf_map_meta_equal(), which does not compare max_entries.  When a
percpu array serves as an inner map, replacing it with one that has
fewer max_entries bypasses the check.  Since percpu_array_map_gen_lookup()
inlines the original template's index_mask as a JIT immediate, a lookup
on the replacement map can access pptrs[] out of bounds.

Point percpu_array_map_ops.map_meta_equal to array_map_meta_equal(),
which already enforces the max_entries equality check.

Add a selftest to verify that replacing a percpu array inner map with
a differently-sized one is rejected.

Fixes: db69718b8efa ("bpf: inline bpf_map_lookup_elem() for PERCPU_ARRAY maps")
Signed-off-by: Guannan Wang &lt;wgnbuaa@gmail.com&gt;
Acked-by: Mykyta Yatsenko &lt;yatsenko@meta.com&gt;
Link: https://lore.kernel.org/r/20260514074454.77491-1-wgnbuaa@gmail.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

</content>
</entry>
</feed>
