Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: uprobes integration test on Go binaries fails on kernel < 4.14 #406

Closed
mmat11 opened this issue Sep 7, 2021 · 8 comments
Closed

ci: uprobes integration test on Go binaries fails on kernel < 4.14 #406

mmat11 opened this issue Sep 7, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@mmat11
Copy link
Contributor

mmat11 commented Sep 7, 2021

This test should pass once this get fixed

@ti-mo
Copy link
Collaborator

ti-mo commented Jan 21, 2022

@mmat11 Is there a plan to move forward with this? If you don't have the resources to investigate this in the near future, maybe best to add a comment to the API and close this up.

@ti-mo ti-mo added the bug Something isn't working label Jan 21, 2022
@mmat11
Copy link
Contributor Author

mmat11 commented Jan 21, 2022

Hi @ti-mo , I forgot about this issue (and haven't had much time to investigate anyway). I'll try to investigate it soon

@mmat11
Copy link
Contributor Author

mmat11 commented Feb 3, 2022

I've retested on a debian 9 VM and it works:

bpf prog
SEC("uprobe/traceme")
int uprobe_traceme(struct pt_regs *ctx) {
	bpf_printk("OK");
	return 0;
}
tracer
...
ex, err := link.OpenExecutable("/tmp/tracee")
if err != nil {
    log.Fatalf("opening executable: %s", err)
}

up, err := ex.Uretprobe("main.traceme", objs.UprobeTraceme, nil)
if err != nil {
    log.Fatalf("creating uprobe: %s", err)
}
defer up.Close()
...

tracee
func main() {
	for {
		time.Sleep(time.Second)
		traceme(1, 2)
	}
}

//go:noinline
func traceme(a, b int) {
	fmt.Println(a + b)
}
matt@debian9-univ:~$ /tmp/tracee
3
3
3
^C

matt@debian9-univ:~$ sudo cat /sys/kernel/debug/tracing/trace_pipe
[sudo] password for matt: 
tracee-7677  [006] ....  7341.527519: : OK
tracee-7677  [006] ....  7342.527641: : OK
tracee-7677  [006] ....  7343.527723: : OK

matt@debian9-univ:~$ uname -r
4.9.0-13-amd64

matt@debian9-univ:~$ cat /boot/config-4.9.0-13-amd64 |grep -e BPF -e UPROBE -e FUNCTION_TRACER
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_UPROBES=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_HAVE_FUNCTION_TRACER=y
CONFIG_FUNCTION_TRACER=y
CONFIG_UPROBE_EVENT=y
CONFIG_BPF_EVENTS=y
CONFIG_TEST_BPF=m

So my guess would be that the CI kernel is missing some config?

@lmb
Copy link
Collaborator

lmb commented Feb 4, 2022

From my most recent build:

lorenz@altair:~/dev/ci-kernels/build/linux-4.9.299 (master)
$ grep -e BPF -e UPROBE -e FUNCTION_TRACER .config
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_UPROBES=y
# CONFIG_NET_CLS_BPF is not set
# CONFIG_NET_ACT_BPF is not set
CONFIG_BPF_JIT=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_HAVE_FUNCTION_TRACER=y
CONFIG_FUNCTION_TRACER=y
CONFIG_UPROBE_EVENT=y
CONFIG_BPF_EVENTS=y
# CONFIG_TEST_BPF is not set

@lmb
Copy link
Collaborator

lmb commented Feb 4, 2022

Still doesn't work against the CI kernel:

$ ./run-tests.sh 4.9 -v -run UprobeProgramCall/go-binary ./link
Fetching linux-4.9.bz
Fetching linux-4.9-selftests-bpf.tgz
No selftests found, disabling
Testing on 4.9
qemu-system-x86_64: -fsdev local,id=virtfs1,path=/,security_model=none,readonly,multidevs=remap: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
qemu-system-x86_64: -fsdev local,id=virtfs5,path=/home/lorenz/.local/lib/python3.9/site-packages/virtme/guest,security_model=none,readonly,multidevs=remap: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
qemu-system-x86_64: -fsdev local,id=virtfs17,path=/tmp/tmp.fuZkDvjfpg,security_model=none,readonly,multidevs=remap: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
qemu-system-x86_64: warning: 9p: degraded performance: a reasonable high msize should be chosen on client/guest side (chosen msize is <= 8192). See https://wiki.qemu.org/Documentation/9psetup#msize for details.
=== RUN   TestUprobeProgramCall
=== RUN   TestUprobeProgramCall/go-binary
    kprobe_test.go:365: unexpected value: want '1', got '0'
--- FAIL: TestUprobeProgramCall (0.04s)
    --- FAIL: TestUprobeProgramCall/go-binary (0.04s)
FAIL
FAIL	github.com/cilium/ebpf/link	1.110s
FAIL

@mmat11 mmat11 changed the title Uprobes on Go binaries silently fail on kernel < 4.14 ci: uprobes integration test on Go binaries fails on kernel < 4.14 Feb 21, 2022
@mmat11
Copy link
Contributor Author

mmat11 commented Feb 21, 2022

I've renamed the issue so it's less scary :). As written on slack, I've tested this manually with two different 4.9 kernels and the uprobe fires, so it's most likely some CI issue.
I need some other time to understand what is wrong though

@lmb
Copy link
Collaborator

lmb commented Feb 22, 2022

Yeah, fair enough. FWIW the uprobe readline example doesn't reliably trigger on my machine, maybe related?

@lmb
Copy link
Collaborator

lmb commented May 14, 2024

4.14 is EOL, closing this issue.

@lmb lmb closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants