Skip to content

Commit

Permalink
link/kprobe: Allow . in symbol name
Browse files Browse the repository at this point in the history
Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
  • Loading branch information
chenhengqi committed Mar 17, 2022
1 parent bf256fd commit 8812d01
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion link/kprobe.go
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime"
"sync"
"unsafe"
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8812d01

Please sign in to comment.