Skip to content

Commit 2475f59

Browse files
Peter Oskolkovdavem330
authored andcommitted
ipv6: discard IP frag queue on more errors
This is similar to how ipv4 now behaves: commit 0ff89ef ("ip: fail fast on IP defrag errors"). Signed-off-by: Peter Oskolkov <posk@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 075e264 commit 2475f59

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/ipv6/reassembly.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
145145
*/
146146
if (end < fq->q.len ||
147147
((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len))
148-
goto err;
148+
goto discard_fq;
149149
fq->q.flags |= INET_FRAG_LAST_IN;
150150
fq->q.len = end;
151151
} else {
@@ -162,20 +162,20 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
162162
if (end > fq->q.len) {
163163
/* Some bits beyond end -> corruption. */
164164
if (fq->q.flags & INET_FRAG_LAST_IN)
165-
goto err;
165+
goto discard_fq;
166166
fq->q.len = end;
167167
}
168168
}
169169

170170
if (end == offset)
171-
goto err;
171+
goto discard_fq;
172172

173173
/* Point into the IP datagram 'data' part. */
174174
if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data))
175-
goto err;
175+
goto discard_fq;
176176

177177
if (pskb_trim_rcsum(skb, end - offset))
178-
goto err;
178+
goto discard_fq;
179179

180180
/* Find out which fragments are in front and at the back of us
181181
* in the chain of fragments so far. We must know where to put
@@ -418,6 +418,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
418418
rcu_read_lock();
419419
__IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
420420
rcu_read_unlock();
421+
inet_frag_kill(&fq->q);
421422
return -1;
422423
}
423424

0 commit comments

Comments
 (0)