netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bpf: fix a return in sockmap_get_from_fd()
@ 2017-08-18  7:27 Dan Carpenter
  2017-08-18  7:40 ` John Fastabend
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-08-18  7:27 UTC (permalink / raw)
  To: Alexei Starovoitov, John Fastabend
  Cc: Daniel Borkmann, netdev, kernel-janitors

"map" is a valid pointer.  We wanted to return "err" instead.  Also
let's return a zero literal at the end.

Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index d2f2bdf71ffa..b8cb1b3c9bfb 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1125,11 +1125,11 @@ static int sockmap_get_from_fd(const union bpf_attr *attr, int ptype)
 		fdput(f);
 		bpf_prog_put(prog1);
 		bpf_prog_put(prog2);
-		return PTR_ERR(map);
+		return err;
 	}
 
 	fdput(f);
-	return err;
+	return 0;
 }
 
 static int bpf_prog_attach(const union bpf_attr *attr)

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

* Re: [PATCH net-next] bpf: fix a return in sockmap_get_from_fd()
  2017-08-18  7:27 [PATCH net-next] bpf: fix a return in sockmap_get_from_fd() Dan Carpenter
@ 2017-08-18  7:40 ` John Fastabend
  2017-08-18  8:21 ` Daniel Borkmann
  2017-08-18 17:18 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2017-08-18  7:40 UTC (permalink / raw)
  To: Dan Carpenter, Alexei Starovoitov
  Cc: Daniel Borkmann, netdev, kernel-janitors

On 08/18/2017 12:27 AM, Dan Carpenter wrote:
> "map" is a valid pointer.  We wanted to return "err" instead.  Also
> let's return a zero literal at the end.
> 
> Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index d2f2bdf71ffa..b8cb1b3c9bfb 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c

Thanks, just a note though the sockmap attach call can not fail so
this branch is effectively never used. We could just remove the
branch but having an unchecked 'err' code seems fragile if we ever
do find a reason to fail in the attach path.

Acked-by: John Fastabend <john.fastabend@gmail.com>

> @@ -1125,11 +1125,11 @@ static int sockmap_get_from_fd(const union bpf_attr *attr, int ptype)
>  		fdput(f);
>  		bpf_prog_put(prog1);
>  		bpf_prog_put(prog2);
> -		return PTR_ERR(map);
> +		return err;
>  	}
>  
>  	fdput(f);
> -	return err;
> +	return 0;
>  }
>  
>  static int bpf_prog_attach(const union bpf_attr *attr)
> 

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

* Re: [PATCH net-next] bpf: fix a return in sockmap_get_from_fd()
  2017-08-18  7:27 [PATCH net-next] bpf: fix a return in sockmap_get_from_fd() Dan Carpenter
  2017-08-18  7:40 ` John Fastabend
@ 2017-08-18  8:21 ` Daniel Borkmann
  2017-08-18 17:18 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2017-08-18  8:21 UTC (permalink / raw)
  To: Dan Carpenter, Alexei Starovoitov, John Fastabend; +Cc: netdev, kernel-janitors

On 08/18/2017 09:27 AM, Dan Carpenter wrote:
> "map" is a valid pointer.  We wanted to return "err" instead.  Also
> let's return a zero literal at the end.
>
> Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

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

* Re: [PATCH net-next] bpf: fix a return in sockmap_get_from_fd()
  2017-08-18  7:27 [PATCH net-next] bpf: fix a return in sockmap_get_from_fd() Dan Carpenter
  2017-08-18  7:40 ` John Fastabend
  2017-08-18  8:21 ` Daniel Borkmann
@ 2017-08-18 17:18 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-18 17:18 UTC (permalink / raw)
  To: dan.carpenter; +Cc: ast, john.fastabend, daniel, netdev, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 18 Aug 2017 10:27:02 +0300

> "map" is a valid pointer.  We wanted to return "err" instead.  Also
> let's return a zero literal at the end.
> 
> Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

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

end of thread, other threads:[~2017-08-18 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18  7:27 [PATCH net-next] bpf: fix a return in sockmap_get_from_fd() Dan Carpenter
2017-08-18  7:40 ` John Fastabend
2017-08-18  8:21 ` Daniel Borkmann
2017-08-18 17:18 ` 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).