]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.181/net-gro-fix-use-after-free-read-in-napi_gro_frags.patch
Linux 4.9.181
[thirdparty/kernel/stable-queue.git] / releases / 4.4.181 / net-gro-fix-use-after-free-read-in-napi_gro_frags.patch
1 From foo@baz Fri 31 May 2019 03:55:52 PM PDT
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Wed, 29 May 2019 15:36:10 -0700
4 Subject: net-gro: fix use-after-free read in napi_gro_frags()
5
6 From: Eric Dumazet <edumazet@google.com>
7
8 [ Upstream commit a4270d6795b0580287453ea55974d948393e66ef ]
9
10 If a network driver provides to napi_gro_frags() an
11 skb with a page fragment of exactly 14 bytes, the call
12 to gro_pull_from_frag0() will 'consume' the fragment
13 by calling skb_frag_unref(skb, 0), and the page might
14 be freed and reused.
15
16 Reading eth->h_proto at the end of napi_frags_skb() might
17 read mangled data, or crash under specific debugging features.
18
19 BUG: KASAN: use-after-free in napi_frags_skb net/core/dev.c:5833 [inline]
20 BUG: KASAN: use-after-free in napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
21 Read of size 2 at addr ffff88809366840c by task syz-executor599/8957
22
23 CPU: 1 PID: 8957 Comm: syz-executor599 Not tainted 5.2.0-rc1+ #32
24 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
25 Call Trace:
26 __dump_stack lib/dump_stack.c:77 [inline]
27 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
28 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
29 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
30 kasan_report+0x12/0x20 mm/kasan/common.c:614
31 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/generic_report.c:142
32 napi_frags_skb net/core/dev.c:5833 [inline]
33 napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
34 tun_get_user+0x2f3c/0x3ff0 drivers/net/tun.c:1991
35 tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2037
36 call_write_iter include/linux/fs.h:1872 [inline]
37 do_iter_readv_writev+0x5f8/0x8f0 fs/read_write.c:693
38 do_iter_write fs/read_write.c:970 [inline]
39 do_iter_write+0x184/0x610 fs/read_write.c:951
40 vfs_writev+0x1b3/0x2f0 fs/read_write.c:1015
41 do_writev+0x15b/0x330 fs/read_write.c:1058
42
43 Fixes: a50e233c50db ("net-gro: restore frag0 optimization")
44 Signed-off-by: Eric Dumazet <edumazet@google.com>
45 Reported-by: syzbot <syzkaller@googlegroups.com>
46 Signed-off-by: David S. Miller <davem@davemloft.net>
47 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
48 ---
49 net/core/dev.c | 2 +-
50 1 file changed, 1 insertion(+), 1 deletion(-)
51
52 --- a/net/core/dev.c
53 +++ b/net/core/dev.c
54 @@ -4550,7 +4550,6 @@ static struct sk_buff *napi_frags_skb(st
55 skb_reset_mac_header(skb);
56 skb_gro_reset_offset(skb);
57
58 - eth = skb_gro_header_fast(skb, 0);
59 if (unlikely(skb_gro_header_hard(skb, hlen))) {
60 eth = skb_gro_header_slow(skb, hlen, 0);
61 if (unlikely(!eth)) {
62 @@ -4558,6 +4557,7 @@ static struct sk_buff *napi_frags_skb(st
63 return NULL;
64 }
65 } else {
66 + eth = (const struct ethhdr *)skb->data;
67 gro_pull_from_frag0(skb, hlen);
68 NAPI_GRO_CB(skb)->frag0 += hlen;
69 NAPI_GRO_CB(skb)->frag0_len -= hlen;