net: sock: fix access via invalid file descriptor
authorAlexei Starovoitov <ast@plumgrid.com>
Thu, 11 Dec 2014 04:14:55 +0000 (20:14 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Dec 2014 04:34:27 +0000 (23:34 -0500)
commit198bf1b046e370a7d3987b195cff5f1efebec3ac
treebf46fa99273ce89e4d7f3ff2e000ec6fc41b9cb7
parentf95b414edb18de59940dcebbefb49cf25c6d505c
net: sock: fix access via invalid file descriptor

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c