From b6345dcc9fff025c6c454608e03fb215fe1b139f Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Tue, 14 Jun 2022 11:23:13 +0300 Subject: [PATCH] Fix `go_crypto_tls_ex_uprobe` --- tap/tlstapper/bpf/go_uprobes.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tap/tlstapper/bpf/go_uprobes.c b/tap/tlstapper/bpf/go_uprobes.c index aff9a8fca..a7bc6dde9 100644 --- a/tap/tlstapper/bpf/go_uprobes.c +++ b/tap/tlstapper/bpf/go_uprobes.c @@ -132,6 +132,15 @@ static __always_inline void go_crypto_tls_ex_uprobe(struct pt_regs *ctx, struct return; } + // In case of read, the length is determined on return + if (flags == FLAGS_IS_READ_BIT) { + info.buffer_len = GO_ABI_INTERNAL_PT_REGS_R1(ctx); // n in return n, nil + // This check achieves ignoring 0 length reads (the reads result with an error) + if (info.buffer_len == 0) { + return; + } + } + output_ssl_chunk(ctx, &info, info.buffer_len, pid_tgid, flags); return;