netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bpf: don't indicate success when copy_from_user fails
@ 2017-07-27 19:02 Daniel Borkmann
  2017-07-29  8:17 ` Martin KaFai Lau
  2017-07-29 21:29 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Borkmann @ 2017-07-27 19:02 UTC (permalink / raw)
  To: davem; +Cc: kafai, alexei.starovoitov, netdev, Daniel Borkmann

err in bpf_prog_get_info_by_fd() still holds 0 at that time from prior
check_uarg_tail_zero() check. Explicitly return -EFAULT instead, so
user space can be notified of buggy behavior.

Fixes: 1e2709769086 ("bpf: Add BPF_OBJ_GET_INFO_BY_FD")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 kernel/bpf/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 045646d..84bb399 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1289,7 +1289,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
 	info_len = min_t(u32, sizeof(info), info_len);
 
 	if (copy_from_user(&info, uinfo, info_len))
-		return err;
+		return -EFAULT;
 
 	info.type = prog->type;
 	info.id = prog->aux->id;
-- 
1.9.3

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

* Re: [PATCH net] bpf: don't indicate success when copy_from_user fails
  2017-07-27 19:02 [PATCH net] bpf: don't indicate success when copy_from_user fails Daniel Borkmann
@ 2017-07-29  8:17 ` Martin KaFai Lau
  2017-07-29 21:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Martin KaFai Lau @ 2017-07-29  8:17 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, kafai, alexei.starovoitov, netdev

On Fri, Jul 28, 2017 at 3:02 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> err in bpf_prog_get_info_by_fd() still holds 0 at that time from prior
> check_uarg_tail_zero() check. Explicitly return -EFAULT instead, so
> user space can be notified of buggy behavior.
Thanks for fixing it. (I am on PTO and cannot use my usual email account).

Acked-by: Martin KaFai Lau <kafai@fb.com>

>
> Fixes: 1e2709769086 ("bpf: Add BPF_OBJ_GET_INFO_BY_FD")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  kernel/bpf/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 045646d..84bb399 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -1289,7 +1289,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
>         info_len = min_t(u32, sizeof(info), info_len);
>
>         if (copy_from_user(&info, uinfo, info_len))
> -               return err;
> +               return -EFAULT;
>
>         info.type = prog->type;
>         info.id = prog->aux->id;
> --
> 1.9.3
>

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

* Re: [PATCH net] bpf: don't indicate success when copy_from_user fails
  2017-07-27 19:02 [PATCH net] bpf: don't indicate success when copy_from_user fails Daniel Borkmann
  2017-07-29  8:17 ` Martin KaFai Lau
@ 2017-07-29 21:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-07-29 21:29 UTC (permalink / raw)
  To: daniel; +Cc: kafai, alexei.starovoitov, netdev

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu, 27 Jul 2017 21:02:46 +0200

> err in bpf_prog_get_info_by_fd() still holds 0 at that time from prior
> check_uarg_tail_zero() check. Explicitly return -EFAULT instead, so
> user space can be notified of buggy behavior.
> 
> Fixes: 1e2709769086 ("bpf: Add BPF_OBJ_GET_INFO_BY_FD")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Applied, thanks.

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

end of thread, other threads:[~2017-07-29 21:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-27 19:02 [PATCH net] bpf: don't indicate success when copy_from_user fails Daniel Borkmann
2017-07-29  8:17 ` Martin KaFai Lau
2017-07-29 21:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).