Bug 492050

Summary: Valgrind does not understand some eBPF commands passed into the bpf syscalls
Product: [Developer tools] valgrind Reporter: William Cohen <wcohen>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: REPORTED ---    
Severity: minor CC: pjfloyd, sam
Priority: NOR    
Version First Reported In: 3.23.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=492125
https://bugs.kde.org/show_bug.cgi?id=478774
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description William Cohen 2024-08-22 19:30:23 UTC
SUMMARY
When attempting to track down the root cause of a valgrind complaint about unitialized fields in some PCP code I noticed that valgrind would print out messages in the following in the output:

--1794549-- WARNING: unhandled eBPF command 28
--1794549-- WARNING: unhandled eBPF command 35

The command 28 and 35 map to BPF_LINK_CREATE and  BPF_PROG_BIND_MAP, respectively.  The handling of things the bpf syscall handles is incomplete.

STEPS TO REPRODUCE on Fedora 40 as root:
1.  dnf install pcp-pmda-bpf valgrind
2.  touch /var/lib/pcp/pmdas/bpf/.NeedInstall
3.  systemctl restart pmcd
4. valgrind pminfo -L -K clear -K add,157,/var/lib/pcp/pmdas/bpf/pmda_bpf,bpf_init -dmtT bpf.disk bpf.runq 

OBSERVED RESULT

The output has a number of messages about  "unhandled eBPF command ..."


EXPECTED RESULT

No messages about unhandled eBPF commands in the output

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Fedora 40 pcp-pmda-bpf-6.2.2-3.fc39.x86_64 valgrind-3.22.0-4.fc39.x86_64

ADDITIONAL INFORMATION

The last command in the list that valgrind understands is BPF_MAP_FREEZE. There looks to be a number of additional BPF commands after BPF_MAP_FREEZE listed on the 6.11 kernel:
https://elixir.bootlin.com/linux/v6.11-rc4/source/include/uapi/linux/bpf.h#L922
Comment 1 Paul Floyd 2024-08-23 05:43:12 UTC
Maybe a duplicate of 478774. Can you test the second patch attached to that bugzilla item?
Comment 2 William Cohen 2024-08-26 18:49:17 UTC
This bug is not a duplicate of 478774.  The bug 478774 is tracking the size of objects initialized by the kernel.  This bug is filed due to some of the eBPF commands not being handled by valgrind.  Just to be sure the reproducer was run with a version of valgrind that included the patch from 478774.  The warnings about unhandled eBPF commands were still present on the patched version of valgrind.
Comment 3 Paul Floyd 2024-08-27 05:48:51 UTC
OK thanks.  When I started looking at 478774 I realized that much has changed since Valgrind last was updated for eBPF. Just adding all the missing eBPF data structures is a fairly significant chunk.

I think that when we update eBPF we should tackle this and 478774 and 492125 all in one go.