Skip to content

Commit

Permalink
Backport grpc uninitialized fix (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
grcevski authored Mar 1, 2024
1 parent 9cd9845 commit 636e7a0
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bpf/go_grpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,13 @@ int uprobe_server_handleStream_return(struct pt_regs *ctx) {
// Read the embedded object ptr
bpf_probe_read(&st_ptr, sizeof(st_ptr), (void *)(stream_ptr + grpc_stream_st_ptr_pos + sizeof(void *)));

if (st_ptr) {
trace->host_len = 0;
trace->remote_addr_len = 0;
trace->host_port = 0;
__builtin_memset(trace->host, 0, sizeof(trace->host));
__builtin_memset(trace->remote_addr, 0, sizeof(trace->remote_addr));

if (st_ptr) {
void *remote_addr = 0;
void *local_addr = 0;

Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/ebpf/common/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ func extractHostPort(b []uint8) (string, int) {
}

func extractIP(b []uint8, size int) string {
// Temporary fix to avoid crashes if the data is not correct.
// We saw issues with peer location changes in grpc 1.60
if size < 0 || size > 4096 {
return ""
}

if size > len(b) {
size = len(b)
}
Expand Down
Binary file modified pkg/internal/ebpf/grpc/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_debug_bpfel_x86.o
Binary file not shown.

0 comments on commit 636e7a0

Please sign in to comment.