← Back to Pull requests

[CNM-5818] fix(network): Load fentry tracer on kernels without tcp_recvmsg addr_len #58700

Closed
unknown closed this pull request without merging on Nov 07, 2026 01:28 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 18:55 UTC
Author

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_len argument from tcp_recvmsg/udp_recvmsg/udpv6_recvmsg (8341c989ac77, merged for 7.1). Our fexit/tcp_recvmsg program still declared addr_len, so it read the return value from the wrong ctx slot and the verifier rejected it:

program tcp_recvmsg_exit: load program: permission denied:
func 'tcp_recvmsg' doesn't have 6-th argument: invalid bpf_context access off=40 size=8

  • Adds a 4-arg tcp_recvmsg_exit_no_addr_len variant and picks the tcp_recvmsg exit 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 returns fentry.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).

  • Adds GetKernelFuncProto and GetKernelFuncArgCount to pkg/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-RE KernelTypes, which is a configured btf_path when one is set. They mirror getBTFFuncProto/GetBTFFunctionArgCount in CWS's constantfetch. 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.

  • Adds unit tests for the helper and the selection.
  • 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):

  • Ubuntu 26.04, kernel 7.0.0-38: TestTracerSuite/fentry 108 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 that tcp_recvmsg_exit_no_addr_len is 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.

  • Ubuntu 24.04, kernel 6.8: TestTracerSuite/fentry 108 pass / 0 fail / 5 skip; the unit tests read 5 params from BTF and check that tcp_recvmsg_exit is 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_accept on RHEL 9.6+, plus the UDP entry programs), CNM-5857 (UDP exit programs declare only sk), CNM-5858 (fentry counts TCP MSG_PEEK reads; 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

    Diff: 515 lines (+386 / -129) across 6 files Reviewer: usamasaqib Review duration: 21993m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #58700"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 47.7% (MEDIUM) · Higher = larger blast radius
    47.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 18.8% · Safe to merge
    18.8%