Skip to content

Commit df25455

Browse files
w1ldptrdavem330
authored andcommitted
netfilter: nf_conntrack: allow early drop of offloaded UDP conns
Both synchronous early drop algorithm and asynchronous gc worker completely ignore connections with IPS_OFFLOAD_BIT status bit set. With new functionality that enabled UDP NEW connection offload in action CT malicious user can flood the conntrack table with offloaded UDP connections by just sending a single packet per 5tuple because such connections can no longer be deleted by early drop algorithm. To mitigate the issue allow both early drop and gc to consider offloaded UDP connections for deletion. Signed-off-by: Vlad Buslov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6a9bad0 commit df25455

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/netfilter/nf_conntrack_core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,6 @@ static unsigned int early_drop_list(struct net *net,
13711371
hlist_nulls_for_each_entry_rcu(h, n, head, hnnode) {
13721372
tmp = nf_ct_tuplehash_to_ctrack(h);
13731373

1374-
if (test_bit(IPS_OFFLOAD_BIT, &tmp->status))
1375-
continue;
1376-
13771374
if (nf_ct_is_expired(tmp)) {
13781375
nf_ct_gc_expired(tmp);
13791376
continue;
@@ -1443,11 +1440,14 @@ static bool gc_worker_skip_ct(const struct nf_conn *ct)
14431440
static bool gc_worker_can_early_drop(const struct nf_conn *ct)
14441441
{
14451442
const struct nf_conntrack_l4proto *l4proto;
1443+
u8 protonum = nf_ct_protonum(ct);
14461444

1445+
if (test_bit(IPS_OFFLOAD_BIT, &ct->status) && protonum != IPPROTO_UDP)
1446+
return false;
14471447
if (!test_bit(IPS_ASSURED_BIT, &ct->status))
14481448
return true;
14491449

1450-
l4proto = nf_ct_l4proto_find(nf_ct_protonum(ct));
1450+
l4proto = nf_ct_l4proto_find(protonum);
14511451
if (l4proto->can_early_drop && l4proto->can_early_drop(ct))
14521452
return true;
14531453

@@ -1504,7 +1504,8 @@ static void gc_worker(struct work_struct *work)
15041504

15051505
if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) {
15061506
nf_ct_offload_timeout(tmp);
1507-
continue;
1507+
if (!nf_conntrack_max95)
1508+
continue;
15081509
}
15091510

15101511
if (expired_count > GC_SCAN_EXPIRED_MAX) {

0 commit comments

Comments
 (0)