net: bpf: correctly handle errors in sk_attach_filter()
authorSasha Levin <sasha.levin@oracle.com>
Sat, 13 Sep 2014 04:06:30 +0000 (00:06 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Sep 2014 21:37:49 +0000 (17:37 -0400)
commitc0d1379a19c3dde3c32be50164997d246241c1e4
treebab2f0bb3c42e17d571f8fcc20bffa5ebd89e2ab
parent3fc8867740b4a0bf56f372c6f5ddd14970962fb1
net: bpf: correctly handle errors in sk_attach_filter()

Commit "net: bpf: make eBPF interpreter images read-only" has changed bpf_prog
to be vmalloc()ed but never handled some of the errors paths of the old code.

On error within sk_attach_filter (which userspace can easily trigger), we'd
kfree() the vmalloc()ed memory, and leak the internal bpf_work_struct.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c