Skip to content

Commit 988dc4a

Browse files
LorenzoBianconidavem330
authored andcommitted
net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv
gue tunnels run iptunnel_pull_offloads on received skbs. This can determine a possible use-after-free accessing guehdr pointer since the packet will be 'uncloned' running pskb_expand_head if it is a cloned gso skb (e.g if the packet has been sent though a veth device) Fixes: a09a4c8 ("tunnels: Remove encapsulation offloads on decap") Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d184153 commit 988dc4a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/ipv4/fou.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
121121
struct guehdr *guehdr;
122122
void *data;
123123
u16 doffset = 0;
124+
u8 proto_ctype;
124125

125126
if (!fou)
126127
return 1;
@@ -212,13 +213,14 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
212213
if (unlikely(guehdr->control))
213214
return gue_control_message(skb, guehdr);
214215

216+
proto_ctype = guehdr->proto_ctype;
215217
__skb_pull(skb, sizeof(struct udphdr) + hdrlen);
216218
skb_reset_transport_header(skb);
217219

218220
if (iptunnel_pull_offloads(skb))
219221
goto drop;
220222

221-
return -guehdr->proto_ctype;
223+
return -proto_ctype;
222224

223225
drop:
224226
kfree_skb(skb);

0 commit comments

Comments
 (0)