aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2018-07-31 00:50:29 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-31 17:41:29 -0400
commit4672694bd4f1aebdab0ad763ae4716e89cb15221 (patch)
tree71ef2910c68a577125a93f6b696a3f13c1b26562
parent56e2c94f055d328f5f6b0a5c1721cca2f2d4e0a1 (diff)
ipv4: frags: handle possible skb truesize change
ip_frag_queue() might call pskb_pull() on one skb that is already in the fragment queue. We need to take care of possible truesize change, or we might have an imbalance of the netns frags memory usage. IPv6 is immune to this bug, because RFC5722, Section 4, amended by Errata ID 3089 states : When reassembling an IPv6 datagram, if one or more its constituent fragments is determined to be an overlapping fragment, the entire datagram (and any constituent fragments) MUST be silently discarded. Fixes: 158f323b9868 ("net: adjust skb->truesize in pskb_expand_head()") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/ip_fragment.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 8e9528ebaa8e..d14d741fb05e 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -383,11 +383,16 @@ found:
383 int i = end - next->ip_defrag_offset; /* overlap is 'i' bytes */ 383 int i = end - next->ip_defrag_offset; /* overlap is 'i' bytes */
384 384
385 if (i < next->len) { 385 if (i < next->len) {
386 int delta = -next->truesize;
387
386 /* Eat head of the next overlapped fragment 388 /* Eat head of the next overlapped fragment
387 * and leave the loop. The next ones cannot overlap. 389 * and leave the loop. The next ones cannot overlap.
388 */ 390 */
389 if (!pskb_pull(next, i)) 391 if (!pskb_pull(next, i))
390 goto err; 392 goto err;
393 delta += next->truesize;
394 if (delta)
395 add_frag_mem_limit(qp->q.net, delta);
391 next->ip_defrag_offset += i; 396 next->ip_defrag_offset += i;
392 qp->q.meat -= i; 397 qp->q.meat -= i;
393 if (next->ip_summed != CHECKSUM_UNNECESSARY) 398 if (next->ip_summed != CHECKSUM_UNNECESSARY)