Patch "net: ipv6: RTF_PCPU should not be settable from userspace" has been added to the 4.10-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
net: ipv6: RTF_PCPU should not be settable from userspace
to the 4.10-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:
net-ipv6-rtf_pcpu-should-not-be-settable-from-userspace.patch
and it can be found in the queue-4.10 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 Sat Apr 29 08:22:40 CEST 2017
From: David Ahern <[email protected]>
Date: Wed, 19 Apr 2017 14:19:43 -0700
Subject: net: ipv6: RTF_PCPU should not be settable from userspace
From: David Ahern <[email protected]>
[ Upstream commit 557c44be917c322860665be3d28376afa84aa936 ]
Andrey reported a fault in the IPv6 route code:
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN Modules linked in: CPU: 1 PID: 4035 Comm: a.out Not tainted 4.11.0-rc7+ #250 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff880069809600 task.stack: ffff880062dc8000 RIP: 0010:ip6_rt_cache_alloc+0xa6/0x560 net/ipv6/route.c:975 RSP: 0018:ffff880062dced30 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: ffff8800670561c0 RCX: 0000000000000006 RDX: 0000000000000003 RSI: ffff880062dcfb28 RDI: 0000000000000018 RBP: ffff880062dced68 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: ffff880062dcfb28 R14: dffffc0000000000 R15: 0000000000000000 FS: 00007feebe37e7c0(0000) GS:ffff88006cb00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000205a0fe4 CR3: 000000006b5c9000 CR4: 00000000000006e0 Call Trace: ip6_pol_route+0x1512/0x1f20 net/ipv6/route.c:1128 ip6_pol_route_output+0x4c/0x60 net/ipv6/route.c:1212
...
Andrey's syzkaller program passes rtmsg.rtmsg_flags with the RTF_PCPU bit set. Flags passed to the kernel are blindly copied to the allocated rt6_info by ip6_route_info_create making a newly inserted route appear as though it is a per-cpu route. ip6_rt_cache_alloc sees the flag set and expects rt->dst.from to be set - which it is not since it is not really a per-cpu copy. The subsequent call to __ip6_dst_alloc then generates the fault.
Fix by checking for the flag and failing with EINVAL.
--- include/uapi/linux/ipv6_route.h | 2 +- net/ipv6/route.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
include/uapi/linux/ipv6_route.h +1 -1
@@ -34,7 +34,7 @@#define RTF_PREF (pref) ((pref) << 27)#define RTF_PREF_MASK 0x18000000 -#define RTF_PCPU 0x40000000 +#define RTF_PCPU 0x40000000/* read-only: can not be set by user */ #define RTF_LOCAL 0x80000000
net/ipv6/route.c +4 -0
@@ -1831,6 +1831,10 @@ static struct rt6_info *ip6_route_info_cint addr_type;int err = -EINVAL ; +/* RTF_PCPU is an internal flag; can not be set by userspace */ +if (cfg->fc_flags &RTF_PCPU ) + goto out; +if (cfg->fc_dst_len >128 || cfg->fc_src_len >128 ) goto out;#ifndef CONFIG_IPV6_SUBTREES
Patches currently in stable-queue which might be from [email protected] are
queue-4.10/ipv6-fix-idev-addr_list-corruption.patch queue-4.10/net-ipv6-regenerate-host-route-if-moved-to-gc-list.patch queue-4.10/net-ipv6-rtf_pcpu-should-not-be-settable-from-userspace.patch queue-4.10/net-vrf-fix-setting-nlm_f_excl-flag-when-adding-l3mdev-rule.patch