Skip to content

Commit

Permalink
link: Allow kprobe multi to be disabled in kernel
Browse files Browse the repository at this point in the history
Kprobe multi support is gated on CONFIG_FPROBE, without it creating the
link fails with ENOTSUP: https://elixir.bootlin.com/linux/latest/source/include/linux/fprobe.h#L56

Unfortunately the standard Debian sid kernel does not have it enabled.

Update the kprobe multi test to handle ENOTSUP, and drop the minimum
kernel version check, tests otherwise fail with:

Feature 'bpf_link_kprobe_multi' isn't supported even though kernel v5.19.11 is newer than v5.18
  • Loading branch information
arthurfabre committed Oct 6, 2022
1 parent 8fceee5 commit 7c6a2b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/unix/types_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
EFAULT = linux.EFAULT
EACCES = linux.EACCES
EILSEQ = linux.EILSEQ
ENOTSUP = linux.ENOTSUP
)

const (
Expand Down
1 change: 1 addition & 0 deletions internal/unix/types_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
EFAULT
EACCES
EILSEQ
ENOTSUP
)

// Constants are distinct to avoid breaking switch statements.
Expand Down
8 changes: 5 additions & 3 deletions link/kprobe_multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (kml *kprobeMultiLink) Unpin() error {
return fmt.Errorf("unpin kprobe_multi: %w", ErrNotSupported)
}

var haveBPFLinkKprobeMulti = internal.FeatureTest("bpf_link_kprobe_multi", "5.18", func() error {
var haveBPFLinkKprobeMulti = internal.FeatureTest("bpf_link_kprobe_multi", "0.0", func() error {
prog, err := ebpf.NewProgram(&ebpf.ProgramSpec{
Name: "probe_kpm_link",
Type: ebpf.Kprobe,
Expand Down Expand Up @@ -167,9 +167,11 @@ var haveBPFLinkKprobeMulti = internal.FeatureTest("bpf_link_kprobe_multi", "5.18
if errors.Is(err, unix.EINVAL) {
return internal.ErrNotSupported
}
if err != nil {
return err
// If CONFIG_FPROBE isn't set.
if errors.Is(err, unix.ENOTSUP) {
return internal.ErrNotSupported
}

fd.Close()

return nil
Expand Down

0 comments on commit 7c6a2b2

Please sign in to comment.