(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

selftests/bpf: Fix map fd leak in no-BTF wq test

bpf_map__reuse_fd() duplicates the supplied file descriptor instead of taking ownership of it. test_failure_map_no_btf() closes the original map_fd only when reuse fails, leaking it when reuse succeeds, including when the test passes. Destroying the skeleton closes its own descriptor but leaves the original descriptor and its map reference alive. Close map_fd immediately after bpf_map__reuse_fd(), before checking its return value, to release the original descriptor on both success and failure. The skeleton retains its own descriptor for the subsequent program load. Fixes: bca2b74ea9a8 ("selftests/bpf: Add more bpf_wq tests") Reported-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Yun Lu <luyun@kylinos.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20261013030114.292157-1-luyun_611@163.com


Author Yun Lu Committer Daniel Borkmann Date Commit Parent 33cbc5c2
+2 -3
1 changed file
+2 -3
1 changed file