[CNM-5818] fix(network): Load fentry tracer on kernels without tcp_recvmsg addr_len #58700
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 515 lines diff across 6 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.374
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #58700"
general
weight: 0.35
usamasaqib
What does this PR do?
Fixes the CO-RE fentry tracer failing to load on Ubuntu's 7.0.0-38 kernel. That kernel backports the upstream removal of the
addr_lenargument fromtcp_recvmsg/udp_recvmsg/udpv6_recvmsg(8341c989ac77, merged for 7.1). Ourfexit/tcp_recvmsgprogram still declaredaddr_len, so it read the return value from the wrong ctx slot and the verifier rejected it:tcp_recvmsg_exit_no_addr_lenvariant and picks thetcp_recvmsgexit variant from the kernel BTF parameter count (6/5/4). If the count can't be read or isn't one of those, the fentry tracer fails to load (an unknown count returnsfentry.ErrorUnsupported) instead of guessing: a variant that declares fewer args than the kernel passes the verifier and silently reads an argument as the return value. As with any fentry load failure today, system-probe's network tracer then doesn't start; fentry is opt-in (network_config.enable_fentry, default false).GetKernelFuncProtoandGetKernelFuncArgCounttopkg/ebpf/btf, shared helpers that read a kernel function's prototype or argument count from a given BTF spec, and uses the count for the check above. The fentry tracer passes the running kernel's BTF (GetKernelSpec()), which the fexit program is attached to and verified against, rather than the CO-REKernelTypes, which is a configuredbtf_pathwhen one is set. They mirrorgetBTFFuncProto/GetBTFFunctionArgCountin CWS'sconstantfetch. CWS code is deliberately not changed here, to avoid a network→security dependency and keep this fix out of a CWS refactor; consolidating them could be a future cleanup.Motivation
CNM-5818, part of the kernel 7.0 upgrade epic CNM-5634. The change landed inside the 7.0 series (Ubuntu 7.0.0-28 still has
addr_len, 7.0.0-38 doesn't; upstream v7.0 still has it), so we can't gate on the kernel version, hence the BTF check.Describe how you validated your changes
On Lima VMs (arm64):
TestTracerSuite/fentry108 pass / 0 fail / 5 skip (before the fix it had 82 failures, all from that verifier error). The unit tests pass: they read 4 params from BTF and check thattcp_recvmsg_exit_no_addr_lenis selected. They take the expected variant from the BTF count rather than pinning a count per kernel, so they only cover the 4-arg path on a kernel that has it.TestTracerSuite/fentry108 pass / 0 fail / 5 skip; the unit tests read 5 params from BTF and check thattcp_recvmsg_exitis selected.Additional Notes
Alternative considered:
bpf_get_func_ret()(5.17+) reads the fexit return value regardless of argument count, which would avoid a new variant per signature change. Not used here: fentry runs from 5.8, and kernels without the helper can also carry signature backports, so they'd still need the BTF count check (two mechanisms instead of one). Tracked as a possible follow-up in CNM-5859.Related follow-ups: CNM-5822 (the same bug class for
inet_csk_accepton RHEL 9.6+, plus the UDP entry programs), CNM-5857 (UDP exit programs declare onlysk), CNM-5858 (fentry counts TCPMSG_PEEKreads; pre-existing), CNM-5891 (validate BTF parameter types, not just the count, when selecting probe variants), CNM-5823.🤖 Generated with Claude Code
[CNM-5818]: https://datadoghq.atlassian.net/browse/CNM-5818?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ