feat(cws): Use a BPF LSM program for setrlimit when available #58071
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 240 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.328
Real PR Conversation Timeline
1 comments
"Review active on #58071"
general
weight: 0.35
brycekahle
What does this PR do?
Adds a
lsm/task_setrlimitvariant of thesecurity_task_setrlimithook used by the setrlimit event. That hook only enriches the syscall cache with the target pid, so the syscall entry/exit probes are unchanged.The LSM program is loaded instead of the kprobe/fentry hook when:
BPF_PROG_TYPE_LSM(CONFIG_BPF_LSM), andbpfis in the active LSM list (/sys/kernel/security/lsm). Otherwise the program loads and attaches but is never called.Only one of the two programs is loaded (the other is excluded from the manager). The event uses a
OneOfselector. If loading fails in BPF LSM mode, the probe logs a warning and retries with the kprobe/fentry hooks, before the existing fentry -> kprobe fallback.New setting:
event_monitoring_config.event_stream.use_bpf_lsm(defaulttrue).Motivation
This is a first step towards BPF LSM in CWS: it validates the loading, selection and fallback plumbing on the simplest hook. Later steps are moving more hooks over and using
BPF_MAP_TYPE_INODE_STORAGE, which can only be used from LSM programs.Tradeoff: LSMs run in
lsm=order and stop at the first denial. If an earlier LSM (e.g. AppArmor rlimit mediation) denies the call, our program doesn't run. The event is still sent with-EPERM, but the target falls back to the caller pid forprlimit64.Describe how you validated your changes
runtime-security,runtime-security-fentryandruntime-security-syscall-wrapperobjects and checked that thelsm/task_setrlimitsection is present.lsm=...,bpf. The existingTestSetrlimitEventfunctional tests (theprlimit64-stackcase exercises the hook) cover whichever flavor gets selected, so they need to run on such a kernel to validate the LSM path.