On 1/19/24 10:05, Kui-Feng Lee wrote:
On 1/18/24 13:56, Martin KaFai Lau wrote:
On 1/17/24 5:49 PM, thinker.li@xxxxxxxxx wrote:
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 0744a1f194fa..ff41f7736618 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -20234,6 +20234,7 @@ static int check_struct_ops_btf_id(struct
bpf_verifier_env *env)
const struct btf_member *member;
struct bpf_prog *prog = env->prog;
u32 btf_id, member_idx;
+ struct btf *btf;
const char *mname;
if (!prog->gpl_compatible) {
@@ -20241,8 +20242,10 @@ static int check_struct_ops_btf_id(struct
bpf_verifier_env *env)
return -EINVAL;
}
+ btf = prog->aux->attach_btf ?: bpf_get_btf_vmlinux();
+
just "btf = prog->aux->attach_btf;" which was assigned to
bpf_get_btf_vmlinux() for the non-module case. Take a look at
bpf_prog_load() in syscall.c
You are right. I have been too protective here.
Just try to remove it. The test case libbpf_probe_prog_types crashes
the kernel for attach_btf is null. It sets neither attach_btf_id nor
attach_prog_fd.