prog: resolve attach target for BPF_LSM_CGROUP programs #2115
@ti-mo do you think you'd be able to review this one :pray: ?
Changes look good to me. Could you please rebase on the latest main to fix CI :pray:
Just wondering if we can't do without this corner case skip somehow. If NewProgram returns ErrNotSupported for an unsupported/missing attach type, this isn't needed. Haven't checked how difficult this would be to add.
Changes look good to me. Could you please rebase on the latest main to fix CI 🙏
Thanks @dylandreimerink ! I've just rebased on the main branch :call_me_hand:
Not trivial, but I gave it a shot in 4d14a3fe74377d3cf15a3fa0aeed25abf183aa79.
Okay, me idly wondering/suggesting something doesn't mean it immediately needs to become a reality. :stuck_out_tongue: You can explore first before committing to it.
This isn't worth adding a probe for, esp. not running it on the unhappy path of NewProgram. In this case I'd add a separate test for AttachLSMCgroup instead of shoehorning it into the TestProgramAttachToKernel matrix. And gate just that test on a specific kernel version.
@ti-mo I misunderstood your comment and wasn't sure whether it's suggestion, NIT or requirement. Nevertheless, I've dropped the probe and moved the case into its own test gated on kernel 6.0. I hope it's enough to ship the fix.
@danielpacak Thanks for bearing with me! I've pushed a small fixup that adds a skip based on a minVersion field in the test matrix; I suggested that approach in a similar PR after I'd already suggested a separate test here. :sweat_smile:
Approved these changes.
ti-mo
danielpacak
lsm_cgroup programs attach to the same bpf_lsm_<hook> functions as lsm
programs, but findProgramTargetInKernel only looked up the target for
AttachLSMMac. An lsm_cgroup program was loaded without attach_btf_id and
the kernel rejected it with "Tracing programs must provide btf_id".
libbpf treats both attach types the same way, see
btf_get_kernel_prefix_kind().
Fixes #2114