Skip to content

Commit b540ca4

Browse files
edumazetZhengShunQian
authored andcommitted
inet: frag: enforce memory limits earlier
[ Upstream commit 56e2c94 ] We currently check current frags memory usage only when a new frag queue is created. This allows attackers to first consume the memory budget (default : 4 MB) creating thousands of frag queues, then sending tiny skbs to exceed high_thresh limit by 2 to 3 order of magnitude. Note that before commit 648700f ("inet: frags: use rhashtables for reassembly units"), work queue could be starved under DOS, getting no cpu cycles. After commit 648700f, only the per frag queue timer can eventually remove an incomplete frag queue and its skbs. Fixes: b13d3cb ("inet: frag: move eviction of queues to work queue") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Jann Horn <[email protected]> Cc: Florian Westphal <[email protected]> Cc: Peter Oskolkov <[email protected]> Cc: Paolo Abeni <[email protected]> Acked-by: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8cfa2a2 commit b540ca4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/ipv4/inet_fragment.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,6 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
364364
{
365365
struct inet_frag_queue *q;
366366

367-
if (frag_mem_limit(nf) > nf->high_thresh) {
368-
inet_frag_schedule_worker(f);
369-
return NULL;
370-
}
371-
372367
q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC);
373368
if (!q)
374369
return NULL;
@@ -405,6 +400,11 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
405400
struct inet_frag_queue *q;
406401
int depth = 0;
407402

403+
if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh) {
404+
inet_frag_schedule_worker(f);
405+
return NULL;
406+
}
407+
408408
if (frag_mem_limit(nf) > nf->low_thresh)
409409
inet_frag_schedule_worker(f);
410410

0 commit comments

Comments
 (0)