All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix bug where garbage collection for nf_conncount is not skipped when jiffies wrap around
@ 2025-02-27 13:32 Jensen, Nicklas Bo
  2025-02-27 15:48 ` Florian Westphal
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jensen, Nicklas Bo @ 2025-02-27 13:32 UTC (permalink / raw)
  To: netfilter-devel@vger.kernel.org

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.

Signed-off-by: Nicklas Bo Jensen <njensen@akamai.com>
---
 net/netfilter/nf_conncount.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c
index 4890af4dc263..ebe38ed2e6f4 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 */
--
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-05 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 13:32 [PATCH] Fix bug where garbage collection for nf_conncount is not skipped when jiffies wrap around Jensen, Nicklas Bo
2025-02-27 15:48 ` Florian Westphal
2025-02-27 15:49 ` Florian Westphal
2025-03-05 21:49 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.