Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpftool: Change pid_iter.bpf.c to comply with the change of bpf_link_fops.

To support epoll, a new instance of file_operations, bpf_link_fops_poll,
has been added for links that support epoll. The pid_iter.bpf.c checks
f_ops for links and other BPF objects. The check should fail for struct_ops
links without this patch.

Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240530065946.979330-9-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Kui-Feng Lee and committed by
Martin KaFai Lau
d14c1fac 1a4b858b

+6 -1
+6 -1
tools/bpf/bpftool/skeleton/pid_iter.bpf.c
··· 29 29 }; 30 30 31 31 extern const void bpf_link_fops __ksym; 32 + extern const void bpf_link_fops_poll __ksym __weak; 32 33 extern const void bpf_map_fops __ksym; 33 34 extern const void bpf_prog_fops __ksym; 34 35 extern const void btf_fops __ksym; ··· 85 84 fops = &btf_fops; 86 85 break; 87 86 case BPF_OBJ_LINK: 88 - fops = &bpf_link_fops; 87 + if (&bpf_link_fops_poll && 88 + file->f_op == &bpf_link_fops_poll) 89 + fops = &bpf_link_fops_poll; 90 + else 91 + fops = &bpf_link_fops; 89 92 break; 90 93 default: 91 94 return 0;