aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2013-04-16 08:55:41 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-17 01:15:29 -0400
commit97599dc792b45b1669c3cdb9a4b365aad0232f65 (patch)
tree77fdf7ed0dfe7b8a9f0fe10663603892e12e8687 /net/ipv6
parent8d7ed0f051caf192994c02fbefb859eac03d1646 (diff)
net: drop dst before queueing fragments
Commit 4a94445c9a5c (net: Use ip_route_input_noref() in input path) added a bug in IP defragmentation handling, as non refcounted dst could escape an RCU protected section. Commit 64f3b9e203bd068 (net: ip_expire() must revalidate route) fixed the case of timeouts, but not the general problem. Tom Parkin noticed crashes in UDP stack and provided a patch, but further analysis permitted us to pinpoint the root cause. Before queueing a packet into a frag list, we must drop its dst, as this dst has limited lifetime (RCU protected) When/if a packet is finally reassembled, we use the dst of the very last skb, still protected by RCU and valid, as the dst of the reassembled packet. Use same logic in IPv6, as there is no need to hold dst references. Reported-by: Tom Parkin <tparkin@katalix.com> Tested-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/reassembly.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 196ab9347ad1..0ba10e53a629 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -330,9 +330,17 @@ found:
330 } 330 }
331 331
332 if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && 332 if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
333 fq->q.meat == fq->q.len) 333 fq->q.meat == fq->q.len) {
334 return ip6_frag_reasm(fq, prev, dev); 334 int res;
335 unsigned long orefdst = skb->_skb_refdst;
336
337 skb->_skb_refdst = 0UL;
338 res = ip6_frag_reasm(fq, prev, dev);
339 skb->_skb_refdst = orefdst;
340 return res;
341 }
335 342
343 skb_dst_drop(skb);
336 inet_frag_lru_move(&fq->q); 344 inet_frag_lru_move(&fq->q);
337 return -1; 345 return -1;
338 346