diff --git a/kern/gotls_kern.c b/kern/gotls_kern.c index 0e7a3006c..4b9e108e3 100644 --- a/kern/gotls_kern.c +++ b/kern/gotls_kern.c @@ -106,7 +106,10 @@ static __always_inline int gotls_write(struct pt_regs *ctx, len_ptr = (void *)go_get_argument(ctx, is_register_abi, 4); bpf_probe_read_kernel(&len, sizeof(len), (void *)&len_ptr); - debug_bpf_printk("gotls_write record_type:%d\n", record_type); + if (len == 0) { + return 0; + } + debug_bpf_printk("gotls_write record_type:%d, len:%d\n", record_type, len); if (record_type != recordTypeApplicationData) { return 0; } @@ -115,7 +118,7 @@ static __always_inline int gotls_write(struct pt_regs *ctx, if (!event) { return 0; } - + len = len & 0xFFFF; event->data_len = len; int ret = bpf_probe_read_user(&event->data, sizeof(event->data), (void *)str); @@ -157,7 +160,10 @@ static __always_inline int gotls_read(struct pt_regs *ctx, // Read函数的返回值第一个是int类型,存放在栈里的顺序是5 ret_len_ptr = (void *)go_get_argument_by_stack(ctx, 5); bpf_probe_read_kernel(&ret_len, sizeof(ret_len), (void *)&ret_len_ptr); - if (len == 0) { + if (len <= 0) { + return 0; + } + if (ret_len <= 0 ) { return 0; } diff --git a/user/config/config_gotls.go b/user/config/config_gotls.go index 6a56d4098..a03024ce9 100644 --- a/user/config/config_gotls.go +++ b/user/config/config_gotls.go @@ -182,7 +182,6 @@ func (gc *GoTLSConfig) Check() error { gc.ReadTlsAddrs, err = gc.findRetOffsetsPie(GoTlsReadFunc) if err != nil { - panic(err) return err } } else { diff --git a/user/module/probe_gotls_text.go b/user/module/probe_gotls_text.go index f1d339882..b21513e13 100644 --- a/user/module/probe_gotls_text.go +++ b/user/module/probe_gotls_text.go @@ -23,6 +23,7 @@ import ( manager "github.com/gojue/ebpfmanager" "golang.org/x/sys/unix" "math" + "strings" ) func (g *GoTLSProbe) setupManagersText() error { @@ -42,7 +43,20 @@ func (g *GoTLSProbe) setupManagersText() error { readSec = "uprobe/gotls_read_stack" readFn = "gotls_read_stack" } + var gotlsConf = g.conf.(*config.GoTLSConfig) + var buildInfo = new(strings.Builder) + for _, setting := range gotlsConf.Buildinfo.Settings { + if setting.Value == "" { + continue + } + buildInfo.WriteString(" ") + buildInfo.WriteString(setting.Key) + buildInfo.WriteString("=") + buildInfo.WriteString(setting.Value) + } g.logger.Printf("%s\teBPF Function Name:%s, isRegisterABI:%t\n", g.Name(), fn, g.isRegisterABI) + g.logger.Printf("%s\tGolang buildInfo version:%s, Params: %s\n", g.Name(), gotlsConf.Buildinfo.GoVersion, buildInfo.String()) + if g.conf.(*config.GoTLSConfig).IsPieBuildMode { // buildmode pie is enabled. g.logger.Printf("%s\tGolang elf buildmode with pie\n", g.Name())