public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: sock: fix access via invalid file descriptor
@ 2014-12-11  4:14 Alexei Starovoitov
  2014-12-11  4:34 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexei Starovoitov @ 2014-12-11  4:14 UTC (permalink / raw)
  To: David S. Miller
  Cc: Fengguang Wu, Dave Jones, Daniel Borkmann, netdev, linux-kernel

0day robot reported the following crash:
[   21.233581] BUG: unable to handle kernel NULL pointer dereference at 0000000000000007
[   21.234709] IP: [<ffffffff8156ebda>] sk_attach_bpf+0x39/0xc2

It's due to bpf_prog_get() returning ERR_PTR.
Check it properly.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Fixes: 89aa075832b0 ("net: sock: allow eBPF programs to be attached to sockets")
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
Silly mistake. I was sure I've checked this error path. Apparently not :(

 net/core/filter.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 8cc3c03078b3..ec9baea10c16 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1103,8 +1103,8 @@ int sk_attach_bpf(u32 ufd, struct sock *sk)
 		return -EPERM;
 
 	prog = bpf_prog_get(ufd);
-	if (!prog)
-		return -EINVAL;
+	if (IS_ERR(prog))
+		return PTR_ERR(prog);
 
 	if (prog->aux->prog_type != BPF_PROG_TYPE_SOCKET_FILTER) {
 		/* valid fd, but invalid program type */
-- 
1.7.9.5

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

* Re: [PATCH net-next] net: sock: fix access via invalid file descriptor
  2014-12-11  4:14 [PATCH net-next] net: sock: fix access via invalid file descriptor Alexei Starovoitov
@ 2014-12-11  4:34 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-12-11  4:34 UTC (permalink / raw)
  To: ast; +Cc: fengguang.wu, davej, dborkman, netdev, linux-kernel

From: Alexei Starovoitov <ast@plumgrid.com>
Date: Wed, 10 Dec 2014 20:14:55 -0800

> 0day robot reported the following crash:
> [   21.233581] BUG: unable to handle kernel NULL pointer dereference at 0000000000000007
> [   21.234709] IP: [<ffffffff8156ebda>] sk_attach_bpf+0x39/0xc2
> 
> It's due to bpf_prog_get() returning ERR_PTR.
> Check it properly.
> 
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Fixes: 89aa075832b0 ("net: sock: allow eBPF programs to be attached to sockets")
> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
> ---
> Silly mistake. I was sure I've checked this error path. Apparently not :(

Applied, thanks Alexei.

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

end of thread, other threads:[~2014-12-11  4:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-11  4:14 [PATCH net-next] net: sock: fix access via invalid file descriptor Alexei Starovoitov
2014-12-11  4:34 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox