capability: don't use /proc/sys/kernel/cap_last_cap #269
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.33) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 152 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.301
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #269"
general
weight: 0.35
AkihiroSuda
The value of /proc/sys/kernel/cap_last_cap is used as the upper bound
in a few loops, and as an index into [2]uint32 capability sets, so a
bogus value (e.g. if something is mounted over /proc) can lead to a
panic or an infinite loop. In addition, /proc may not be mounted.
Instead, ask the kernel directly using prctl(PR_CAPBSET_READ), which
returns EINVAL for a capability the kernel does not know about.
Start from the last known capability (CAP_CHECKPOINT_RESTORE), which is
the last one since Linux 5.9, and go up or down from it until the
validity changes. For most kernels, this takes two syscalls. The upper
limit is 63, which is the highest capability that can be represented
by the kernel capability ABI v3. The lower limit is CAP_WAKE_ALARM,
which is always supported, given the minimum kernel version required
by Go.
Since LastCap no longer reads /proc/sys/kernel/cap_last_cap, change
TestLastCap to check that the two values agree, rather than checking
that LastCap is within a fixed range. Similarly, change
TestListSupported to check the exact list length based on LastCap.
Thanks to Anthropic and Ada Logics who found and validated this.
Fixes: #265
Reported-by: Adam Korczynski <Adam@adalogics.com>