diff --git a/tap/tlstapper/bpf/golang_uprobes.c b/tap/tlstapper/bpf/golang_uprobes.c index c095a3662..7e189f861 100644 --- a/tap/tlstapper/bpf/golang_uprobes.c +++ b/tap/tlstapper/bpf/golang_uprobes.c @@ -18,6 +18,8 @@ struct golang_read_write { __u32 conn_addr; bool is_request; bool is_gzip_chunk; + __u32 len; + __u32 cap; __u8 data[BUFFER_SIZE_READ_WRITE]; }; @@ -56,6 +58,8 @@ static __always_inline int golang_crypto_tls_write_uprobe(struct pt_regs *ctx) { b->conn_addr = ctx->rsi; // go.itab.*net.TCPConn,net.Conn address b->is_request = true; b->is_gzip_chunk = false; + b->len = ctx->rcx; + b->cap = ctx->rdi; struct socket x = { .pid = s->pid, @@ -103,6 +107,8 @@ static __always_inline int golang_crypto_tls_read_uprobe(struct pt_regs *ctx) { b->conn_addr = ctx->rsi; // go.itab.*net.TCPConn,net.Conn address b->is_request = false; b->is_gzip_chunk = false; + b->len = ctx->rcx; + b->cap = ctx->rcx; // no cap info void* stack_addr = (void*)ctx->rsp; __u64 data_p; diff --git a/tap/tlstapper/tls_poller.go b/tap/tlstapper/tls_poller.go index 281621a19..6ecdd7e85 100644 --- a/tap/tlstapper/tls_poller.go +++ b/tap/tlstapper/tls_poller.go @@ -185,12 +185,12 @@ func (p *tlsPoller) pollGolangReadWrite(rd *ringbuf.Reader, emitter api.Emitter, go dissect(p.extension, connection.ClientReader, options) go dissect(p.extension, connection.ServerReader, options) - request := make([]byte, len(b.Data[:])) - copy(request, b.Data[:]) + request := make([]byte, len(b.Data[:b.Len])) + copy(request, b.Data[:b.Len]) connection.ClientReader.send(request) } else { - response := make([]byte, len(b.Data[:])) - copy(response, b.Data[:]) + response := make([]byte, len(b.Data[:b.Len])) + copy(response, b.Data[:b.Len]) connection.ServerReader.send(response) } } diff --git a/tap/tlstapper/tlstapper_bpfeb.go b/tap/tlstapper/tlstapper_bpfeb.go index 27adb327f..c12fd05fd 100644 --- a/tap/tlstapper/tlstapper_bpfeb.go +++ b/tap/tlstapper/tlstapper_bpfeb.go @@ -19,8 +19,10 @@ type tlsTapperGolangReadWrite struct { ConnAddr uint32 IsRequest bool IsGzipChunk bool - Data [524288]uint8 _ [2]byte + Len uint32 + Cap uint32 + Data [524288]uint8 } type tlsTapperTlsChunk struct { diff --git a/tap/tlstapper/tlstapper_bpfeb.o b/tap/tlstapper/tlstapper_bpfeb.o index a2e760e26..17a9b9e90 100644 Binary files a/tap/tlstapper/tlstapper_bpfeb.o and b/tap/tlstapper/tlstapper_bpfeb.o differ diff --git a/tap/tlstapper/tlstapper_bpfel.go b/tap/tlstapper/tlstapper_bpfel.go index 7797b4e94..e11c67f50 100644 --- a/tap/tlstapper/tlstapper_bpfel.go +++ b/tap/tlstapper/tlstapper_bpfel.go @@ -19,8 +19,10 @@ type tlsTapperGolangReadWrite struct { ConnAddr uint32 IsRequest bool IsGzipChunk bool - Data [524288]uint8 _ [2]byte + Len uint32 + Cap uint32 + Data [524288]uint8 } type tlsTapperTlsChunk struct { diff --git a/tap/tlstapper/tlstapper_bpfel.o b/tap/tlstapper/tlstapper_bpfel.o index ad52df0eb..0b0701a70 100644 Binary files a/tap/tlstapper/tlstapper_bpfel.o and b/tap/tlstapper/tlstapper_bpfel.o differ