Bug 492050 - Valgrind does not understand some eBPF commands passed into the bpf syscalls
Summary: Valgrind does not understand some eBPF commands passed into the bpf syscalls
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.23.0
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-22 19:30 UTC by William Cohen
Modified: 2024-08-27 05:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.