kernel.spec: specify VMLINUX_H to initital bpf make only
As discussed in [1], occasionally during CKI builds we are seeing the bpftool install step attempt to re-generate the vmlinux.h header; which fails with:
Error: failed to load BTF from /sys/kernel/btf/vmlinux: Invalid argument
Since RPM_VMLINUX_H isn't set in the %install phase, the bpftool Makefile gets a blank VMLINUX_H= input here. The problem is the vmlinux.h generation rule in bpf is essentially [2]:
$(OUTPUT)vmlinux.h: /sys/kernel/btf/vmlinux
ifeq ($(VMLINUX_H),)
btf dump file $< format c > $@
else
cp "$(VMLINUX_H)" $@
endif
Thus if /sys/kernel/btf/vmlinux is newer, and VMLINUX_H is empty, we can fall into trying to dump from the running kernel. There is no guarantee the built btf is compatible with the build kernel, so we have a race now, where we hope that the /sys/kernel/btf/vmlinux timestamp doesn't update and force the vmlinux.h build. TBH I'm not exactly sure what might trigger this, but I did two ls's back-to-back on my laptop that had been up for some period of time and it changed
$ ls -lh /sys/kernel/btf/vmlinux
-r--r--r--. 1 root root 5.7M May 6 09:57 /sys/kernel/btf/vmlinux
$ ls -lh /sys/kernel/btf/vmlinux
-r--r--r--. 1 root root 5.7M May 13 11:41 /sys/kernel/btf/vmlinux
To avoid this, don't set VMLINUX_H in the main macro, and explictly to /dev/null for the install phase. This way, even if the timestamp is updated, we will just copy in /dev/null. I don't believe the install steps do anything like build against vmlinux.h in any way; but if they did, the file being blank should trigger something to warn us.
Link: infrastructure#340 [1]
Link: https://github.com/libbpf/bpftool/blob/744e0cd8026d3869058b183868ae81cd2402a995/src/Makefile#L202 [2]
Signed-off-by: Ian Wienand iwienand@redhat.com