← Back to Pull requests

prog: resolve attach target for BPF_LSM_CGROUP programs #2115

Merged
danielpacak merged 4 files (66 lines) on Oct 12, 2026 10:18 UTC
View on GitHub
danielpacak danielpacak commented on Sep 24, 2026 20:27 UTC
Author

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

Diff: 66 lines (+30 / -36) across 4 files Reviewer: ti-mo Review duration: 25310m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.33) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 66 lines diff across 4 files
0.33
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.74 · 5 substantive comment(s)
0.74
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.252
Real PR Conversation Timeline
10 items
danielpacak danielpacak commented on Oct 06, 2026 16:19 UTC
Author

@ti-mo do you think you'd be able to review this one :pray: ?

dylandreimerink dylandreimerink commented on Oct 07, 2026 12:22 UTC
Contributor

Changes look good to me. Could you please rebase on the latest main to fix CI :pray:

ti-mo ti-mo commented on code on Oct 07, 2026 12:35 UTC
Code Review
prog_test.go:1
@@ -764,6 +769,9 @@ func TestProgramAttachToKernel(t *testing.T) {
 			if strings.HasPrefix(test.attachTo, "bpf_testmod_") {
 				requireTestmod(t)
 			}
+			if test.attachType == AttachLSMCgroup {

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.

danielpacak danielpacak commented on Oct 07, 2026 13:37 UTC
Author

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:

danielpacak danielpacak commented on code on Oct 07, 2026 13:54 UTC
Code Review
prog_test.go:1
@@ -764,6 +769,9 @@ func TestProgramAttachToKernel(t *testing.T) {
 			if strings.HasPrefix(test.attachTo, "bpf_testmod_") {
 				requireTestmod(t)
 			}
+			if test.attachType == AttachLSMCgroup {

Not trivial, but I gave it a shot in 4d14a3fe74377d3cf15a3fa0aeed25abf183aa79.

ti-mo ti-mo commented on code on Oct 08, 2026 14:48 UTC
Code Review
prog_test.go:1
@@ -764,6 +769,9 @@ func TestProgramAttachToKernel(t *testing.T) {
 			if strings.HasPrefix(test.attachTo, "bpf_testmod_") {
 				requireTestmod(t)
 			}
+			if test.attachType == AttachLSMCgroup {

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.

danielpacak danielpacak commented on code on Oct 08, 2026 16:01 UTC
Code Review
prog_test.go:1
@@ -764,6 +769,9 @@ func TestProgramAttachToKernel(t *testing.T) {
 			if strings.HasPrefix(test.attachTo, "bpf_testmod_") {
 				requireTestmod(t)
 			}
+			if test.attachType == AttachLSMCgroup {

@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.

ti-mo ti-mo commented on Oct 12, 2026 09:43 UTC
Contributor

@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:

ti-mo ti-mo approved these changes on Oct 12, 2026 10:18 UTC
Approved Reviewer

Approved these changes.

Reviewers
Assignees
danielpacak danielpacak
Labels
risk: low confidence: 83.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 32.5% (LOW) · Higher = larger blast radius
32.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 83.7% · Lower = rushed or shallow review
83.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.3% · Safe to merge
5.3%
Repository