Skip to content

Commit f46078c

Browse files
strssndktndavem330
authored andcommitted
ipv6: drop packets with multiple fragmentation headers
It is not allowed for an ipv6 packet to contain multiple fragmentation headers. So discard packets which were already reassembled by fragmentation logic and send back a parameter problem icmp. The updates for RFC 6980 will come in later, I have to do a bit more research here. Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4b08a8f commit f46078c

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎include/linux/ipv6.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct inet6_skb_parm {
101101
#define IP6SKB_FORWARDED 2
102102
#define IP6SKB_REROUTED 4
103103
#define IP6SKB_ROUTERALERT 8
104+
#define IP6SKB_FRAGMENTED 16
104105
};
105106

106107
#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))

‎net/ipv6/reassembly.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
490490
ipv6_hdr(head)->payload_len = htons(payload_len);
491491
ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);
492492
IP6CB(head)->nhoff = nhoff;
493+
IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
493494

494495
/* Yes, and fold redundant checksum back. 8) */
495496
if (head->ip_summed == CHECKSUM_COMPLETE)
@@ -524,6 +525,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
524525
struct net *net = dev_net(skb_dst(skb)->dev);
525526
int evicted;
526527

528+
if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED)
529+
goto fail_hdr;
530+
527531
IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMREQDS);
528532

529533
/* Jumbo payload inhibits frag. header */
@@ -544,6 +548,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
544548
ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMOKS);
545549

546550
IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb);
551+
IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
547552
return 1;
548553
}
549554

0 commit comments

Comments
 (0)