From: Andrii Nakryiko Date: Tue, 8 Dec 2020 06:43:26 +0000 (-0800) Subject: bpf: Return -ENOTSUPP when attaching to non-kernel BTF X-Git-Tag: microblaze-v5.12~172^2~26^2~14 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=8bdd8e275ede9786d845b3ec952836e61fd824e9;p=linux-2.6-microblaze.git bpf: Return -ENOTSUPP when attaching to non-kernel BTF Return -ENOTSUPP if tracing BPF program is attempted to be attached with specified attach_btf_obj_fd pointing to non-kernel (neither vmlinux nor module) BTF object. This scenario might be supported in the future and isn't outright invalid, so -EINVAL isn't the most appropriate error code. Suggested-by: Alexei Starovoitov Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20201208064326.667389-1-andrii@kernel.org --- diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 0cd3cc2af9c1..287be337d5f6 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2121,8 +2121,11 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr) if (IS_ERR(attach_btf)) return -EINVAL; if (!btf_is_kernel(attach_btf)) { + /* attaching through specifying bpf_prog's BTF + * objects directly might be supported eventually + */ btf_put(attach_btf); - return -EINVAL; + return -ENOTSUPP; } } } else if (attr->attach_btf_id) {