Skip to content

Commit 1d18abd

Browse files
edjeegregkh
authored andcommitted
inet: frags: fix defragmented packet's IP header for af_packet
[ Upstream commit 0848f64 ] When ip_frag_queue() computes positions, it assumes that the passed sk_buff does not contain L2 headers. However, when PACKET_FANOUT_FLAG_DEFRAG is used, IP reassembly functions can be called on outgoing packets that contain L2 headers. Also, IPv4 checksum is not corrected after reassembly. Fixes: 7736d33 ("packet: Add pre-defragmentation support for ipv4 fanouts.") Signed-off-by: Edward Hyunkoo Jee <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Willem de Bruijn <[email protected]> Cc: Jerry Chu <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dcdd14e commit 1d18abd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/ipv4/ip_fragment.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
342342
ihl = ip_hdrlen(skb);
343343

344344
/* Determine the position of this fragment. */
345-
end = offset + skb->len - ihl;
345+
end = offset + skb->len - skb_network_offset(skb) - ihl;
346346
err = -EINVAL;
347347

348348
/* Is this the final fragment? */
@@ -372,7 +372,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
372372
goto err;
373373

374374
err = -ENOMEM;
375-
if (!pskb_pull(skb, ihl))
375+
if (!pskb_pull(skb, skb_network_offset(skb) + ihl))
376376
goto err;
377377

378378
err = pskb_trim_rcsum(skb, end - offset);
@@ -613,6 +613,9 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
613613
iph->frag_off = qp->q.max_size ? htons(IP_DF) : 0;
614614
iph->tot_len = htons(len);
615615
iph->tos |= ecn;
616+
617+
ip_send_check(iph);
618+
616619
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMOKS);
617620
qp->q.fragments = NULL;
618621
qp->q.fragments_tail = NULL;

0 commit comments

Comments
 (0)