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 authored and lmb committed Mar 18, 2022
1 parent bf256fd commit 04ab12e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions 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,8 +147,8 @@ 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) {
return nil, fmt.Errorf("symbol '%s' must be alphanumeric or underscore: %w", symbol, errInvalidInput)
if !rgxKprobe.MatchString(symbol) {
return nil, fmt.Errorf("symbol '%s' must be a valid symbol in /proc/kallsyms: %w", symbol, errInvalidInput)
}
if prog.Type() != ebpf.Kprobe {
return nil, fmt.Errorf("eBPF program type %s is not a Kprobe: %w", prog.Type(), errInvalidInput)
Expand Down

0 comments on commit 04ab12e

Please sign in to comment.