From 0ed915a5970dd3f499831577da96b9e832dd00ee Mon Sep 17 00:00:00 2001 From: Mahe Tardy Date: Wed, 14 Aug 2024 14:56:44 +0000 Subject: [PATCH] bpf: satisfy the verifier on v5.3 generic programs Verifier complains with clang-18 compiling bpf_generic_kprobe_v53.o and loading it on 5.4.278. Signed-off-by: Mahe Tardy --- bpf/process/pfilter.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bpf/process/pfilter.h b/bpf/process/pfilter.h index b1bf2d52784..4bd630d05a3 100644 --- a/bpf/process/pfilter.h +++ b/bpf/process/pfilter.h @@ -281,6 +281,13 @@ process_filter_capability_change(__u32 ty, __u32 op, __u32 ns, __u64 val, return PFILTER_REJECT; icaps = init->caps.c[ty]; + + // When compiling bpf_generic_kprobe_v53.o with clang-18 and loading it on + // 5.4.278, the verifier complains than ty could be negative while in this + // context it's just the capability set type (effective, inheritable, or + // permitted), let's blindly remind the verifier it's a u32. + asm volatile("%[ty] &= 0xffffffff;\n" + : [ty] "+r"(ty)); ccaps = c->c[ty]; /* we have a change in the capabilities that we care */