← Back to Pull requests

feat(cws): Use a BPF LSM program for setrlimit when available #58071

Open
unknown opened this pull request with 240 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 13, 2026 14:58 UTC
Author

What does this PR do?

Adds a lsm/task_setrlimit variant of the security_task_setrlimit hook 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:

  • the kernel supports BPF_PROG_TYPE_LSM (CONFIG_BPF_LSM), and

  • bpf is 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 OneOf selector. 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 (default true).

    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 for prlimit64.

    Describe how you validated your changes

  • Built the runtime-security, runtime-security-fentry and runtime-security-syscall-wrapper objects and checked that the lsm/task_setrlimit section is present.

  • Added a unit test for the active-LSM list parsing. Go linters pass on the touched packages.

  • Not yet run on a host booted with lsm=...,bpf. The existing TestSetrlimitEvent functional tests (the prlimit64-stack case exercises the hook) cover whichever flavor gets selected, so they need to run on such a kernel to validate the LSM path.
  • Diff: 240 lines (+180 / -60) across 3 files Reviewer: brycekahle Review duration: 17156m
    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
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 38.7% (MEDIUM) · Higher = larger blast radius
    38.7%
    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: 46.7% · Lower = rushed or shallow review
    46.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: 20.6% · Safe to merge
    20.6%