From 8812d0150be74b264eebe780afd48c28e758c11d Mon Sep 17 00:00:00 2001 From: Hengqi Chen Date: Thu, 17 Mar 2022 11:55:44 +0800 Subject: [PATCH] link/kprobe: Allow `.` in symbol name Signed-off-by: Hengqi Chen --- link/kprobe.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/link/kprobe.go b/link/kprobe.go index 904fe3062..99b55838f 100644 --- a/link/kprobe.go +++ b/link/kprobe.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "regexp" "runtime" "sync" "unsafe" @@ -24,6 +25,11 @@ var ( value uint64 err error }{} + + // Allow `.` in symbol name. GCC-compiled kernel may change symbol name + // to have a `.isra.$n` suffix, like `udp_send_skb.isra.52`. + // See: https://gcc.gnu.org/gcc-10/changes.html + rgxKprobe = regexp.MustCompile("^[a-zA-Z_][0-9a-zA-Z_.]*$") ) type probeType uint8 @@ -141,7 +147,7 @@ func kprobe(symbol string, prog *ebpf.Program, opts *KprobeOptions, ret bool) (* if prog == nil { return nil, fmt.Errorf("prog cannot be nil: %w", errInvalidInput) } - if !rgxTraceEvent.MatchString(symbol) { + if !rgxKprobe.MatchString(symbol) { return nil, fmt.Errorf("symbol '%s' must be alphanumeric or underscore: %w", symbol, errInvalidInput) } if prog.Type() != ebpf.Kprobe {