android_kernel_samsung_a7y1.../net
Jann Horn ecc7a6a6be netfilter: xt_bpf: add overflow checks
[ Upstream commit 6ab405114b0b229151ef06f4e31c7834dd09d0c0 ]

Check whether inputs from userspace are too long (explicit length field too
big or string not null-terminated) to avoid out-of-bounds reads.

As far as I can tell, this can at worst lead to very limited kernel heap
memory disclosure or oopses.

This bug can be triggered by an unprivileged user even if the xt_bpf module
is not loaded: iptables is available in network namespaces, and the xt_bpf
module can be autoloaded.

Triggering the bug with a classic BPF filter with fake length 0x1000 causes
the following KASAN report:

==================================================================
BUG: KASAN: slab-out-of-bounds in bpf_prog_create+0x84/0xf0
Read of size 32768 at addr ffff8801eff2c494 by task test/4627

CPU: 0 PID: 4627 Comm: test Not tainted 4.15.0-rc1+ #1
[...]
Call Trace:
 dump_stack+0x5c/0x85
 print_address_description+0x6a/0x260
 kasan_report+0x254/0x370
 ? bpf_prog_create+0x84/0xf0
 memcpy+0x1f/0x50
 bpf_prog_create+0x84/0xf0
 bpf_mt_check+0x90/0xd6 [xt_bpf]
[...]
Allocated by task 4627:
 kasan_kmalloc+0xa0/0xd0
 __kmalloc_node+0x47/0x60
 xt_alloc_table_info+0x41/0x70 [x_tables]
[...]
The buggy address belongs to the object at ffff8801eff2c3c0
                which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 212 bytes inside of
                2048-byte region [ffff8801eff2c3c0, ffff8801eff2cbc0)
[...]
==================================================================

Fixes: e6f30c731718 ("netfilter: x_tables: add xt_bpf match")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Zubin Mithra <zsm@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-07 14:03:39 +02:00
..
6lowpan 6lowpan: Off by one handling ->nexthdr 2020-04-07 13:41:33 +02:00
9p 9p/virtio: Add cleanup path in p9_virtio_init 2020-04-06 20:04:29 +02:00
802 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
8021q vlan: fix memory leak in vlan_dev_set_egress_priority 2020-04-07 13:29:16 +02:00
appletalk appletalk: Set error code if register_snap_client failed 2020-04-07 12:46:15 +02:00
atm net: atm: Fix potential Spectre v1 vulnerabilities 2020-04-06 15:28:29 +02:00
ax25 ax25: enforce CAP_NET_RAW for raw sockets 2020-04-07 07:37:32 +02:00
batman-adv batman-adv: Fix DAT candidate selection on little endian systems 2020-04-07 13:38:35 +02:00
bluetooth Bluetooth: delete a stray unlock 2020-04-07 13:24:53 +02:00
bridge netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule 2020-04-07 13:41:52 +02:00
caif A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
can can: purge socket error queue on sock destruct 2020-04-06 19:16:48 +02:00
ceph A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
core net: Fix skb->csum update in inet_proto_csum_replace16(). 2020-04-07 13:49:06 +02:00
dcb A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dccp dccp: Fix memleak in __feat_register_sp 2020-04-07 13:36:40 +02:00
decnet decnet: fix DN_IFREQ_SIZE 2020-04-07 12:42:56 +02:00
dns_resolver A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
dsa A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ethernet net: add annotations on hh->hh_len lockless accesses 2020-04-07 13:25:04 +02:00
hsr net: hsr: fix possible NULL deref in hsr_handle_frame() 2020-04-07 13:49:23 +02:00
ieee802154 inet: frags: call inet_frags_fini() after unregister_pernet_subsys() 2020-04-07 13:42:09 +02:00
ipv4 tcp: clear tp->segs_{in|out} in tcp_disconnect() 2020-04-07 13:49:29 +02:00
ipv6 vti[6]: fix packet tx through bpf_redirect() 2020-04-07 13:48:40 +02:00
ipx A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
irda A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
iucv net/af_iucv: always register net_device notifier 2020-04-07 13:42:16 +02:00
key xfrm: clean up xfrm protocol checks 2020-04-06 21:34:53 +02:00
l2tp compat_ioctl: pppoe: fix PPPOEIOCSFWD handling 2020-04-06 20:28:29 +02:00
l3mdev A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
lapb lapb: fixed leak of control-blocks. 2020-04-06 19:03:42 +02:00
llc llc: fix sk_buff refcounting in llc_conn_state_process() 2020-04-07 13:43:36 +02:00
mac80211 mac80211: accept deauth frames in IBSS mode 2020-04-07 13:43:32 +02:00
mac802154 A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mpls A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mptcp A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ncm A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
netfilter netfilter: xt_bpf: add overflow checks 2020-04-07 14:03:39 +02:00
netlabel A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
netlink A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
netrom netrom: hold sock when setting skb->destructor 2020-04-06 20:05:22 +02:00
nfc net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() 2020-04-07 13:22:15 +02:00
openvswitch openvswitch: remove another BUG_ON() 2020-04-07 12:43:36 +02:00
packet packet: fix data-race in fanout_flow_is_huge() 2020-04-07 13:43:55 +02:00
phonet A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
rds net/rds: Fix 'ib_evt_handler_call' element in 'rds_ib_stat_names' 2020-04-07 13:43:22 +02:00
rfkill rfkill: Fix incorrect check to avoid NULL pointer dereference 2020-04-07 13:28:52 +02:00
rose net: rose: fix a possible stack overflow 2020-04-06 12:57:06 +02:00
rxrpc A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sched net_sched: fix an OOB access in cls_tcindex 2020-04-07 13:49:25 +02:00
sctp sctp: free cmd->obj.chunk for the unprocessed SCTP_CMD_REPLY 2020-04-07 13:29:10 +02:00
sunrpc sunrpc: expiry_time should be seconds not timeval 2020-04-07 13:50:16 +02:00
switchdev A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tipc tipc: set sysctl_tipc_rmem and named_timeout right range 2020-04-07 13:41:27 +02:00
unix net: fix warning in af_unix 2020-04-07 12:34:56 +02:00
vmw_vsock VSOCK: bind to random port for VMADDR_PORT_ANY 2020-04-07 12:41:40 +02:00
wimax A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
wireless wireless: wext: avoid gcc -O3 warning 2020-04-07 13:48:38 +02:00
x25 net/x25: fix nonblocking connect 2020-04-07 13:45:13 +02:00
xfrm xfrm: clean up xfrm protocol checks 2020-04-06 21:34:53 +02:00
compat.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
socket.c compat_ioctl: handle SIOCOUTQNSD 2020-04-07 13:37:06 +02:00
sysctl_net.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30