All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF
@ 2020-12-05  3:09 Andrii Nakryiko
  2020-12-05  3:14 ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-12-05  3:09 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii, kernel-team, Alexei Starovoitov

Return -EOPNOTSUPP 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 <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 kernel/bpf/syscall.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0cd3cc2af9c1..7e2bf671c6db 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 -EOPNOTSUPP;
 			}
 		}
 	} else if (attr->attach_btf_id) {
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF
  2020-12-05  3:09 [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF Andrii Nakryiko
@ 2020-12-05  3:14 ` Alexei Starovoitov
  2020-12-07 14:07   ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2020-12-05  3:14 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: bpf, Network Development, Alexei Starovoitov, Daniel Borkmann,
	Kernel Team, Alexei Starovoitov

On Fri, Dec 4, 2020 at 7:11 PM Andrii Nakryiko <andrii@kernel.org> wrote:
> +                               return -EOPNOTSUPP;

$ cd kernel/bpf
$ git grep ENOTSUPP|wc -l
46
$ git grep EOPNOTSUPP|wc -l
11

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF
  2020-12-05  3:14 ` Alexei Starovoitov
@ 2020-12-07 14:07   ` Toke Høiland-Jørgensen
  2020-12-07 16:00     ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-12-07 14:07 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko
  Cc: bpf, Network Development, Alexei Starovoitov, Daniel Borkmann,
	Kernel Team, Alexei Starovoitov

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

> On Fri, Dec 4, 2020 at 7:11 PM Andrii Nakryiko <andrii@kernel.org> wrote:
>> +                               return -EOPNOTSUPP;
>
> $ cd kernel/bpf
> $ git grep ENOTSUPP|wc -l
> 46
> $ git grep EOPNOTSUPP|wc -l
> 11

But also

$ cd kernel/include/uapi
$ git grep ENOTSUPP | wc -l
0
$ git grep EOPNOTSUPP | wc -l
8

(i.e., ENOTSUPP is not defined in userspace headers at all)

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF
  2020-12-07 14:07   ` Toke Høiland-Jørgensen
@ 2020-12-07 16:00     ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2020-12-07 16:00 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team, Alexei Starovoitov

On Mon, Dec 7, 2020 at 6:07 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:
>
> > On Fri, Dec 4, 2020 at 7:11 PM Andrii Nakryiko <andrii@kernel.org> wrote:
> >> +                               return -EOPNOTSUPP;
> >
> > $ cd kernel/bpf
> > $ git grep ENOTSUPP|wc -l
> > 46
> > $ git grep EOPNOTSUPP|wc -l
> > 11
>
> But also
>
> $ cd kernel/include/uapi
> $ git grep ENOTSUPP | wc -l
> 0
> $ git grep EOPNOTSUPP | wc -l
> 8
>
> (i.e., ENOTSUPP is not defined in userspace headers at all)

that's irrelevant. The kernel returns it already. It's a known constant
regardless of .h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-07 16:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05  3:09 [PATCH bpf-next] bpf: return -EOPNOTSUPP when attaching to non-kernel BTF Andrii Nakryiko
2020-12-05  3:14 ` Alexei Starovoitov
2020-12-07 14:07   ` Toke Høiland-Jørgensen
2020-12-07 16:00     ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.