diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index a1c2540374370bc26687e266f0db090783c44e45..ade28c51916572011b0b5b1f3cf0e0944f1cdd47 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -3812,6 +3812,11 @@ static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, * check permissions at attach time. */ return -EPERM; + + ptype = attach_type_to_prog_type(attach_type); + if (prog->type != ptype) + return -EINVAL; + return prog->enforce_expected_attach_type && prog->expected_attach_type != attach_type ? -EINVAL : 0;