summaryrefslogtreecommitdiff
path: root/net/netfilter
diff options
context:
space:
mode:
authorNicklas Bo Jensen <njensen@akamai.com>2025-02-27 13:32:34 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-28 21:58:48 +0100
commit4fe956651221d8874d8ae4d942f73f3e2ad48d9a (patch)
tree6664f3ac83cacdbed70a66db0965dbd53102c401 /net/netfilter
parentfcbacc47d16306c87ad1b820b7a575f6e9eae58b (diff)
downloadlinux-4fe956651221d8874d8ae4d942f73f3e2ad48d9a.tar.gz
linux-4fe956651221d8874d8ae4d942f73f3e2ad48d9a.tar.bz2
linux-4fe956651221d8874d8ae4d942f73f3e2ad48d9a.zip
netfilter: nf_conncount: garbage collection is not skipped when jiffies wrap around
[ Upstream commit df08c94baafb001de6cf44bb7098bb557f36c335 ] nf_conncount is supposed to skip garbage collection if it has already run garbage collection in the same jiffy. Unfortunately, this is broken when jiffies wrap around which this patch fixes. The problem is that last_gc in the nf_conncount_list struct is an u32, but jiffies is an unsigned long which is 8 bytes on my systems. When those two are compared it only works until last_gc wraps around. See bug report: https://bugzilla.netfilter.org/show_bug.cgi?id=1778 for more details. Fixes: d265929930e2 ("netfilter: nf_conncount: reduce unnecessary GC") Signed-off-by: Nicklas Bo Jensen <njensen@akamai.com> Reviewed-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_conncount.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c
index 5885810da412..71869ad46646 100644
--- a/net/netfilter/nf_conncount.c
+++ b/net/netfilter/nf_conncount.c
@@ -132,7 +132,7 @@ static int __nf_conncount_add(struct net *net,
struct nf_conn *found_ct;
unsigned int collect = 0;
- if (time_is_after_eq_jiffies((unsigned long)list->last_gc))
+ if ((u32)jiffies == list->last_gc)
goto add_new_node;
/* check the saved connections */
@@ -234,7 +234,7 @@ bool nf_conncount_gc_list(struct net *net,
bool ret = false;
/* don't bother if we just did GC */
- if (time_is_after_eq_jiffies((unsigned long)READ_ONCE(list->last_gc)))
+ if ((u32)jiffies == READ_ONCE(list->last_gc))
return false;
/* don't bother if other cpu is already doing GC */