* [PATCH net] ipv4: frags: handle possible skb truesize change
@ 2018-07-31 4:50 Eric Dumazet
2018-07-31 21:45 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-07-31 4:50 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet
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>
---
net/ipv4/ip_fragment.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 8e9528ebaa8e1af91172466cc161a83301a217ca..d14d741fb05e571d6d0b03248da77fd993debdee 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -383,11 +383,16 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
int i = end - next->ip_defrag_offset; /* overlap is 'i' bytes */
if (i < next->len) {
+ int delta = -next->truesize;
+
/* Eat head of the next overlapped fragment
* and leave the loop. The next ones cannot overlap.
*/
if (!pskb_pull(next, i))
goto err;
+ delta += next->truesize;
+ if (delta)
+ add_frag_mem_limit(qp->q.net, delta);
next->ip_defrag_offset += i;
qp->q.meat -= i;
if (next->ip_summed != CHECKSUM_UNNECESSARY)
--
2.18.0.345.g5c9ce644c3-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] ipv4: frags: handle possible skb truesize change
2018-07-31 4:50 [PATCH net] ipv4: frags: handle possible skb truesize change Eric Dumazet
@ 2018-07-31 21:45 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-31 21:45 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet
From: Eric Dumazet <edumazet@google.com>
Date: Mon, 30 Jul 2018 21:50:29 -0700
> 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>
Applied and queued up for -stable.
Frankly, I think we should enforce the ipv6 rules for ipv4 too.
There is absolutely no reasonable situation where overlapping fragment
queue entries should arrive. None whatsoever.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-31 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-31 4:50 [PATCH net] ipv4: frags: handle possible skb truesize change Eric Dumazet
2018-07-31 21:45 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).