Skip to content

Commit

Permalink
udp: with udp_segment release on error path
Browse files Browse the repository at this point in the history
Failure __ip_append_data triggers udp_flush_pending_frames, but these
tests happen later. The skb must be freed directly.

Fixes: bec1f6f ("udp: generate gso with UDP_SEGMENT")
Reported-by: Eric Dumazet <[email protected]>
Signed-off-by: Willem de Bruijn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wdebruij authored and davem330 committed Jan 16, 2019
1 parent 1a93526 commit 0f149c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,15 +847,23 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
const int hlen = skb_network_header_len(skb) +
sizeof(struct udphdr);

if (hlen + cork->gso_size > cork->fragsize)
if (hlen + cork->gso_size > cork->fragsize) {
kfree_skb(skb);
return -EINVAL;
if (skb->len > cork->gso_size * UDP_MAX_SEGMENTS)
}
if (skb->len > cork->gso_size * UDP_MAX_SEGMENTS) {
kfree_skb(skb);
return -EINVAL;
if (sk->sk_no_check_tx)
}
if (sk->sk_no_check_tx) {
kfree_skb(skb);
return -EINVAL;
}
if (skb->ip_summed != CHECKSUM_PARTIAL || is_udplite ||
dst_xfrm(skb_dst(skb)))
dst_xfrm(skb_dst(skb))) {
kfree_skb(skb);
return -EIO;
}

skb_shinfo(skb)->gso_size = cork->gso_size;
skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
Expand Down
16 changes: 12 additions & 4 deletions net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,15 +1132,23 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
const int hlen = skb_network_header_len(skb) +
sizeof(struct udphdr);

if (hlen + cork->gso_size > cork->fragsize)
if (hlen + cork->gso_size > cork->fragsize) {
kfree_skb(skb);
return -EINVAL;
if (skb->len > cork->gso_size * UDP_MAX_SEGMENTS)
}
if (skb->len > cork->gso_size * UDP_MAX_SEGMENTS) {
kfree_skb(skb);
return -EINVAL;
if (udp_sk(sk)->no_check6_tx)
}
if (udp_sk(sk)->no_check6_tx) {
kfree_skb(skb);
return -EINVAL;
}
if (skb->ip_summed != CHECKSUM_PARTIAL || is_udplite ||
dst_xfrm(skb_dst(skb)))
dst_xfrm(skb_dst(skb))) {
kfree_skb(skb);
return -EIO;
}

skb_shinfo(skb)->gso_size = cork->gso_size;
skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
Expand Down

0 comments on commit 0f149c9

Please sign in to comment.