forked from Minki/linux
skbuff: revert "skbuff: remove some unnecessary operation in skb_segment_list()"
the commit1ddc3229ad
("skbuff: remove some unnecessary operation in skb_segment_list()") introduces an issue very similar to the one already fixed by commit53475c5dd8
("net: fix use-after-free when UDP GRO with shared fraglist"). If the GSO skb goes though skb_clone() and pskb_expand_head() before entering skb_segment_list(), the latter will unshare the frag_list skbs and will release the old list. With the reverted commit in place, when skb_segment_list() completes, skb->next points to the just released list, and later on the kernel will hit UaF. Note that since commite0e3070a9b
("udp: properly complete L4 GRO over UDP tunnel packet") the critical scenario can be reproduced also receiving UDP over vxlan traffic with: NIC (NETIF_F_GRO_FRAGLIST enabled) -> vxlan -> UDP sink Attaching a packet socket to the NIC will cause skb_clone() and the tunnel decapsulation will call pskb_expand_head(). Fixes:1ddc3229ad
("skbuff: remove some unnecessary operation in skb_segment_list()") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
73d7de66aa
commit
17c3df7078
@ -3773,13 +3773,13 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
|
||||
unsigned int tnl_hlen = skb_tnl_header_len(skb);
|
||||
unsigned int delta_truesize = 0;
|
||||
unsigned int delta_len = 0;
|
||||
struct sk_buff *tail = NULL;
|
||||
struct sk_buff *nskb, *tmp;
|
||||
int err;
|
||||
|
||||
skb_push(skb, -skb_network_offset(skb) + offset);
|
||||
|
||||
skb_shinfo(skb)->frag_list = NULL;
|
||||
skb->next = list_skb;
|
||||
|
||||
do {
|
||||
nskb = list_skb;
|
||||
@ -3797,8 +3797,17 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(err))
|
||||
if (!tail)
|
||||
skb->next = nskb;
|
||||
else
|
||||
tail->next = nskb;
|
||||
|
||||
if (unlikely(err)) {
|
||||
nskb->next = list_skb;
|
||||
goto err_linearize;
|
||||
}
|
||||
|
||||
tail = nskb;
|
||||
|
||||
delta_len += nskb->len;
|
||||
delta_truesize += nskb->truesize;
|
||||
@ -3825,7 +3834,7 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,
|
||||
|
||||
skb_gso_reset(skb);
|
||||
|
||||
skb->prev = nskb;
|
||||
skb->prev = tail;
|
||||
|
||||
if (skb_needs_linearize(skb, features) &&
|
||||
__skb_linearize(skb))
|
||||
|
Loading…
Reference in New Issue
Block a user