Patch "netfilter: xt_bpf: add overflow checks" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
netfilter: xt_bpf: add overflow checks
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
netfilter-xt_bpf-add-overflow-checks.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Fri Feb 23 11:45:09 CET 2018
From: Jann Horn <[email protected]>
Date: Fri, 1 Dec 2017 01:46:07 +0100
Subject: netfilter: xt_bpf: add overflow checks
From: Jann Horn <[email protected]>
[ 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)[...]
==================================================================
--- net/netfilter/xt_bpf.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/netfilter/xt_bpf.c +6 -0
@@ -27,6 +27,9 @@ static int __bpf_mt_check_bytecode(struc {struct sock_fprog_kern program; +if (len >XT_BPF_MAX_NUM_INSTR ) +return -EINVAL ; + program.len = len; program.filter = insns;
@@ -55,6 +58,9 @@ static int __bpf_mt_check_path(const chamm_segment_t oldfs =get_fs ();int retval, fd; +if (strnlen (path,XT_BPF_PATH_MAX ) ==XT_BPF_PATH_MAX ) +return -EINVAL ; +set_fs (KERNEL_DS ); fd =bpf_obj_get_user (path);set_fs (oldfs);
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/netfilter-xt_bpf-add-overflow-checks.patch