From: Weiming Shi Date: Fri, 3 Apr 2026 13:29:51 +0000 (+0800) Subject: selftests/bpf: add get_next_key boundary test for cgroup_storage X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=262b857da6bee528420514690895ed7d2c65077e;p=thirdparty%2Fkernel%2Flinux.git selftests/bpf: add get_next_key boundary test for cgroup_storage Verify that bpf_map__get_next_key() correctly returns -ENOENT when called on the last (and only) key in a cgroup_storage map. Before the fix in the previous patch, this would succeed with bogus key data instead of failing. Suggested-by: Paul Chaignon Signed-off-by: Weiming Shi Acked-by: Paul Chaignon Link: https://lore.kernel.org/r/20260403132951.43533-3-bestswngs@gmail.com Signed-off-by: Alexei Starovoitov --- diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_storage.c b/tools/testing/selftests/bpf/prog_tests/cgroup_storage.c index cf395715ced47..5451a43b3563e 100644 --- a/tools/testing/selftests/bpf/prog_tests/cgroup_storage.c +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_storage.c @@ -86,6 +86,11 @@ void test_cgroup_storage(void) err = SYS_NOFAIL(PING_CMD); ASSERT_OK(err, "sixth ping"); + err = bpf_map__get_next_key(skel->maps.cgroup_storage, &key, &key, + sizeof(key)); + ASSERT_ERR(err, "bpf_map__get_next_key should fail"); + ASSERT_EQ(errno, ENOENT, "no second key"); + cleanup_progs: cgroup_storage__destroy(skel); cleanup_network: