From c1db417a412f5ae0bba09f762ce594d331fcdc81 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 19 Dec 2023 21:59:05 +0000 Subject: [PATCH] tetragon: Use ebpf/cilium feature test for large instructions Signed-off-by: Jiri Olsa --- pkg/bpf/detect.go | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/pkg/bpf/detect.go b/pkg/bpf/detect.go index 4fdb6eab8fa..e728f78c273 100644 --- a/pkg/bpf/detect.go +++ b/pkg/bpf/detect.go @@ -24,10 +24,9 @@ type Feature struct { } var ( - kprobeMulti Feature - buildid Feature - modifyReturn Feature - largeProgramSize Feature + kprobeMulti Feature + buildid Feature + modifyReturn Feature ) func HasOverrideHelper() bool { @@ -127,32 +126,8 @@ func HasModifyReturn() bool { return modifyReturn.detected } -func detectLargeProgramSize() bool { - insns := asm.Instructions{} - - for i := 0; i < 4096; i++ { - insns = append(insns, asm.Mov.Imm(asm.R0, 1)) - } - insns = append(insns, asm.Return()) - - prog, err := ebpf.NewProgram(&ebpf.ProgramSpec{ - Type: ebpf.Kprobe, - Instructions: insns, - AttachType: ebpf.AttachModifyReturn, - License: "MIT", - }) - if err != nil { - return false - } - prog.Close() - return true -} - func HasProgramLargeSize() bool { - largeProgramSize.init.Do(func() { - largeProgramSize.detected = detectLargeProgramSize() - }) - return largeProgramSize.detected + return features.HaveLargeInstructions() == nil } func LogFeatures() string {