]>
Commit | Line | Data |
---|---|---|
3fefb5f6 GKH |
1 | From foo@baz Thu Mar 14 23:19:55 PDT 2019 |
2 | From: Eric Dumazet <edumazet@google.com> | |
3 | Date: Wed, 6 Mar 2019 10:41:00 -0800 | |
4 | Subject: fou, fou6: avoid uninit-value in gue_err() and gue6_err() | |
5 | ||
6 | From: Eric Dumazet <edumazet@google.com> | |
7 | ||
8 | [ Upstream commit 5355ed6388e23b69a00d48398a68d022135e6486 ] | |
9 | ||
10 | My prior commit missed the fact that these functions | |
11 | were using udp_hdr() (aka skb_transport_header()) | |
12 | to get access to GUE header. | |
13 | ||
14 | Since pskb_transport_may_pull() does not exist yet, we have to add | |
15 | transport_offset to our pskb_may_pull() calls. | |
16 | ||
17 | BUG: KMSAN: uninit-value in gue_err+0x514/0xfa0 net/ipv4/fou.c:1032 | |
18 | CPU: 1 PID: 10648 Comm: syz-executor.1 Not tainted 5.0.0+ #11 | |
19 | Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 | |
20 | Call Trace: | |
21 | <IRQ> | |
22 | __dump_stack lib/dump_stack.c:77 [inline] | |
23 | dump_stack+0x173/0x1d0 lib/dump_stack.c:113 | |
24 | kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:600 | |
25 | __msan_warning+0x82/0xf0 mm/kmsan/kmsan_instr.c:313 | |
26 | gue_err+0x514/0xfa0 net/ipv4/fou.c:1032 | |
27 | __udp4_lib_err_encap_no_sk net/ipv4/udp.c:571 [inline] | |
28 | __udp4_lib_err_encap net/ipv4/udp.c:626 [inline] | |
29 | __udp4_lib_err+0x12e6/0x1d40 net/ipv4/udp.c:665 | |
30 | udp_err+0x74/0x90 net/ipv4/udp.c:737 | |
31 | icmp_socket_deliver net/ipv4/icmp.c:767 [inline] | |
32 | icmp_unreach+0xb65/0x1070 net/ipv4/icmp.c:884 | |
33 | icmp_rcv+0x11a1/0x1950 net/ipv4/icmp.c:1066 | |
34 | ip_protocol_deliver_rcu+0x584/0xbb0 net/ipv4/ip_input.c:208 | |
35 | ip_local_deliver_finish net/ipv4/ip_input.c:234 [inline] | |
36 | NF_HOOK include/linux/netfilter.h:289 [inline] | |
37 | ip_local_deliver+0x624/0x7b0 net/ipv4/ip_input.c:255 | |
38 | dst_input include/net/dst.h:450 [inline] | |
39 | ip_rcv_finish net/ipv4/ip_input.c:414 [inline] | |
40 | NF_HOOK include/linux/netfilter.h:289 [inline] | |
41 | ip_rcv+0x6bd/0x740 net/ipv4/ip_input.c:524 | |
42 | __netif_receive_skb_one_core net/core/dev.c:4973 [inline] | |
43 | __netif_receive_skb net/core/dev.c:5083 [inline] | |
44 | process_backlog+0x756/0x10e0 net/core/dev.c:5923 | |
45 | napi_poll net/core/dev.c:6346 [inline] | |
46 | net_rx_action+0x78b/0x1a60 net/core/dev.c:6412 | |
47 | __do_softirq+0x53f/0x93a kernel/softirq.c:293 | |
48 | invoke_softirq kernel/softirq.c:375 [inline] | |
49 | irq_exit+0x214/0x250 kernel/softirq.c:416 | |
50 | exiting_irq+0xe/0x10 arch/x86/include/asm/apic.h:536 | |
51 | smp_apic_timer_interrupt+0x48/0x70 arch/x86/kernel/apic/apic.c:1064 | |
52 | apic_timer_interrupt+0x2e/0x40 arch/x86/entry/entry_64.S:814 | |
53 | </IRQ> | |
54 | RIP: 0010:finish_lock_switch+0x2b/0x40 kernel/sched/core.c:2597 | |
55 | Code: 48 89 e5 53 48 89 fb e8 63 e7 95 00 8b b8 88 0c 00 00 48 8b 00 48 85 c0 75 12 48 89 df e8 dd db 95 00 c6 00 00 c6 03 00 fb 5b <5d> c3 e8 4e e6 95 00 eb e7 66 90 66 2e 0f 1f 84 00 00 00 00 00 55 | |
56 | RSP: 0018:ffff888081a0fc80 EFLAGS: 00000296 ORIG_RAX: ffffffffffffff13 | |
57 | RAX: ffff88821fd6bd80 RBX: ffff888027898000 RCX: ccccccccccccd000 | |
58 | RDX: ffff88821fca8d80 RSI: ffff888000000000 RDI: 00000000000004a0 | |
59 | RBP: ffff888081a0fc80 R08: 0000000000000002 R09: ffff888081a0fb08 | |
60 | R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001 | |
61 | R13: ffff88811130e388 R14: ffff88811130da00 R15: ffff88812fdb7d80 | |
62 | finish_task_switch+0xfc/0x2d0 kernel/sched/core.c:2698 | |
63 | context_switch kernel/sched/core.c:2851 [inline] | |
64 | __schedule+0x6cc/0x800 kernel/sched/core.c:3491 | |
65 | schedule+0x15b/0x240 kernel/sched/core.c:3535 | |
66 | freezable_schedule include/linux/freezer.h:172 [inline] | |
67 | do_nanosleep+0x2ba/0x980 kernel/time/hrtimer.c:1679 | |
68 | hrtimer_nanosleep kernel/time/hrtimer.c:1733 [inline] | |
69 | __do_sys_nanosleep kernel/time/hrtimer.c:1767 [inline] | |
70 | __se_sys_nanosleep+0x746/0x960 kernel/time/hrtimer.c:1754 | |
71 | __x64_sys_nanosleep+0x3e/0x60 kernel/time/hrtimer.c:1754 | |
72 | do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 | |
73 | entry_SYSCALL_64_after_hwframe+0x63/0xe7 | |
74 | RIP: 0033:0x4855a0 | |
75 | Code: 00 00 48 c7 c0 d4 ff ff ff 64 c7 00 16 00 00 00 31 c0 eb be 66 0f 1f 44 00 00 83 3d b1 11 5d 00 00 75 14 b8 23 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 04 e2 f8 ff c3 48 83 ec 08 e8 3a 55 fd ff | |
76 | RSP: 002b:0000000000a4fd58 EFLAGS: 00000246 ORIG_RAX: 0000000000000023 | |
77 | RAX: ffffffffffffffda RBX: 0000000000085780 RCX: 00000000004855a0 | |
78 | RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000a4fd60 | |
79 | RBP: 00000000000007ec R08: 0000000000000001 R09: 0000000000ceb940 | |
80 | R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000008 | |
81 | R13: 0000000000a4fdb0 R14: 0000000000085711 R15: 0000000000a4fdc0 | |
82 | ||
83 | Uninit was created at: | |
84 | kmsan_save_stack_with_flags mm/kmsan/kmsan.c:205 [inline] | |
85 | kmsan_internal_poison_shadow+0x92/0x150 mm/kmsan/kmsan.c:159 | |
86 | kmsan_kmalloc+0xa6/0x130 mm/kmsan/kmsan_hooks.c:176 | |
87 | kmsan_slab_alloc+0xe/0x10 mm/kmsan/kmsan_hooks.c:185 | |
88 | slab_post_alloc_hook mm/slab.h:445 [inline] | |
89 | slab_alloc_node mm/slub.c:2773 [inline] | |
90 | __kmalloc_node_track_caller+0xe9e/0xff0 mm/slub.c:4398 | |
91 | __kmalloc_reserve net/core/skbuff.c:140 [inline] | |
92 | __alloc_skb+0x309/0xa20 net/core/skbuff.c:208 | |
93 | alloc_skb include/linux/skbuff.h:1012 [inline] | |
94 | alloc_skb_with_frags+0x186/0xa60 net/core/skbuff.c:5287 | |
95 | sock_alloc_send_pskb+0xafd/0x10a0 net/core/sock.c:2091 | |
96 | sock_alloc_send_skb+0xca/0xe0 net/core/sock.c:2108 | |
97 | __ip_append_data+0x34cd/0x5000 net/ipv4/ip_output.c:998 | |
98 | ip_append_data+0x324/0x480 net/ipv4/ip_output.c:1220 | |
99 | icmp_push_reply+0x23d/0x7e0 net/ipv4/icmp.c:375 | |
100 | __icmp_send+0x2ea3/0x30f0 net/ipv4/icmp.c:737 | |
101 | icmp_send include/net/icmp.h:47 [inline] | |
102 | ipv4_link_failure+0x6d/0x230 net/ipv4/route.c:1190 | |
103 | dst_link_failure include/net/dst.h:427 [inline] | |
104 | arp_error_report+0x106/0x1a0 net/ipv4/arp.c:297 | |
105 | neigh_invalidate+0x359/0x8e0 net/core/neighbour.c:992 | |
106 | neigh_timer_handler+0xdf2/0x1280 net/core/neighbour.c:1078 | |
107 | call_timer_fn+0x285/0x600 kernel/time/timer.c:1325 | |
108 | expire_timers kernel/time/timer.c:1362 [inline] | |
109 | __run_timers+0xdb4/0x11d0 kernel/time/timer.c:1681 | |
110 | run_timer_softirq+0x2e/0x50 kernel/time/timer.c:1694 | |
111 | __do_softirq+0x53f/0x93a kernel/softirq.c:293 | |
112 | ||
113 | Fixes: 26fc181e6cac ("fou, fou6: do not assume linear skbs") | |
114 | Signed-off-by: Eric Dumazet <edumazet@google.com> | |
115 | Reported-by: syzbot <syzkaller@googlegroups.com> | |
116 | Cc: Stefano Brivio <sbrivio@redhat.com> | |
117 | Cc: Sabrina Dubroca <sd@queasysnail.net> | |
118 | Acked-by: Stefano Brivio <sbrivio@redhat.com> | |
119 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
120 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
121 | --- | |
122 | net/ipv4/fou.c | 4 ++-- | |
123 | net/ipv6/fou6.c | 4 ++-- | |
124 | 2 files changed, 4 insertions(+), 4 deletions(-) | |
125 | ||
126 | --- a/net/ipv4/fou.c | |
127 | +++ b/net/ipv4/fou.c | |
128 | @@ -1024,7 +1024,7 @@ static int gue_err(struct sk_buff *skb, | |
129 | int ret; | |
130 | ||
131 | len = sizeof(struct udphdr) + sizeof(struct guehdr); | |
132 | - if (!pskb_may_pull(skb, len)) | |
133 | + if (!pskb_may_pull(skb, transport_offset + len)) | |
134 | return -EINVAL; | |
135 | ||
136 | guehdr = (struct guehdr *)&udp_hdr(skb)[1]; | |
137 | @@ -1059,7 +1059,7 @@ static int gue_err(struct sk_buff *skb, | |
138 | ||
139 | optlen = guehdr->hlen << 2; | |
140 | ||
141 | - if (!pskb_may_pull(skb, len + optlen)) | |
142 | + if (!pskb_may_pull(skb, transport_offset + len + optlen)) | |
143 | return -EINVAL; | |
144 | ||
145 | guehdr = (struct guehdr *)&udp_hdr(skb)[1]; | |
146 | --- a/net/ipv6/fou6.c | |
147 | +++ b/net/ipv6/fou6.c | |
148 | @@ -94,7 +94,7 @@ static int gue6_err(struct sk_buff *skb, | |
149 | int ret; | |
150 | ||
151 | len = sizeof(struct udphdr) + sizeof(struct guehdr); | |
152 | - if (!pskb_may_pull(skb, len)) | |
153 | + if (!pskb_may_pull(skb, transport_offset + len)) | |
154 | return -EINVAL; | |
155 | ||
156 | guehdr = (struct guehdr *)&udp_hdr(skb)[1]; | |
157 | @@ -129,7 +129,7 @@ static int gue6_err(struct sk_buff *skb, | |
158 | ||
159 | optlen = guehdr->hlen << 2; | |
160 | ||
161 | - if (!pskb_may_pull(skb, len + optlen)) | |
162 | + if (!pskb_may_pull(skb, transport_offset + len + optlen)) | |
163 | return -EINVAL; | |
164 | ||
165 | guehdr = (struct guehdr *)&udp_hdr(skb)[1]; |