Skip to content

Fix gRPC server conn user memory reads#2522

Open
MrAlias wants to merge 1 commit into
open-telemetry:mainfrom
MrAlias:grpc-server-conn-user
Open

Fix gRPC server conn user memory reads#2522
MrAlias wants to merge 1 commit into
open-telemetry:mainfrom
MrAlias:grpc-server-conn-user

Conversation

@MrAlias

@MrAlias MrAlias commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Prevent a kernel-memory disclosure by avoiding kernel-space bpf_probe_read dereferences of pointer values sourced from instrumented Go user memory for gRPC server transports.
  • Keep the existing functionality of extracting Go net.Conn/netFD/address details for telemetry while ensuring all pointer chasing of user-origin memory uses user helpers.

Description

  • Added read_user_ip_and_port, get_conn_info_from_user_fd, fd_ptr_from_user_conn, and get_conn_info_from_user_conn to bpf/gotracer/go_common.h to traverse Go connection pointer chains using bpf_probe_read_user for all user-originated dereferences.
  • Updated grpc_server_conn_info in bpf/gotracer/go_grpc.c to call get_conn_info_from_user_conn after reading http2Server.conn with bpf_probe_read_user so the entire chain remains on the user-memory read path.
  • Labeled the user-memory debug log path so it can be distinguished from the generic helper when BPF debug logging is enabled.
  • Changes are minimal and scoped to the gRPC server transport connection path and its helpers.

Testing

  • go test ./pkg/ebpf/common
  • clang -target bpf -D__TARGET_ARCH_x86 -O2 -g -I bpf -c bpf/gotracer/gotracer.c -o .tmp/gotracer.o

Keep gRPC server connection pointer traversal on the user-memory read
path after the transport pointer is read from Go memory. This avoids
generic pointer chasing with kernel read helpers for values sourced from
instrumented Go memory.

Label the debug output so the user-memory path can be distinguished from
the generic helper when BPF debug logging is enabled.
@MrAlias MrAlias added this to the v0.10.0 milestone Jun 26, 2026
@MrAlias MrAlias added bug Something isn't working ebpf Issues or PRs that primarily require eBPF program changes area: tracing Trace context, span construction, and trace attribute behavior labels Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.15%. Comparing base (b9fe20e) to head (6202241).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2522      +/-   ##
==========================================
+ Coverage   69.03%   69.15%   +0.12%     
==========================================
  Files         348      348              
  Lines       47314    47314              
==========================================
+ Hits        32663    32721      +58     
+ Misses      12598    12530      -68     
- Partials     2053     2063      +10     
Flag Coverage Δ
integration-test 51.17% <ø> (+1.23%) ⬆️
integration-test-arm 27.05% <ø> (+0.76%) ⬆️
integration-test-vm-5.15-lts 27.92% <ø> (+0.08%) ⬆️
integration-test-vm-6.18-lts 28.03% <ø> (+1.21%) ⬆️
k8s-integration-test 35.70% <ø> (-0.48%) ⬇️
oats-test 35.49% <ø> (-0.09%) ⬇️
unittests 63.54% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MrAlias MrAlias marked this pull request as ready for review June 26, 2026 20:51
@MrAlias MrAlias requested a review from a team as a code owner June 26, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tracing Trace context, span construction, and trace attribute behavior bug Something isn't working ebpf Issues or PRs that primarily require eBPF program changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant