* [PATCH ulogd2] nfct: fix counter-reset without hashtable
@ 2025-03-25 0:24 Corubba Smith
2025-03-25 5:56 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Corubba Smith @ 2025-03-25 0:24 UTC (permalink / raw)
To: netfilter-devel
The dump_reset_handler will try to update the hashtable regardless of
whether it is used (and thus initialized), which results in a segfault
if it isn't. Instead just short-circuit the handler, and skip any
further result processing because it's not used in this case anyway.
All flow counters in conntrack are reset regardless of the return value
of the handler/callback.
Signed-off-by: Corubba Smith <corubba@gmx.de>
---
input/flow/ulogd_inpflow_NFCT.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/input/flow/ulogd_inpflow_NFCT.c b/input/flow/ulogd_inpflow_NFCT.c
index 93edb76..cdda741 100644
--- a/input/flow/ulogd_inpflow_NFCT.c
+++ b/input/flow/ulogd_inpflow_NFCT.c
@@ -989,6 +989,9 @@ dump_reset_handler(enum nf_conntrack_msg_type type,
int ret = NFCT_CB_CONTINUE, rc, id;
struct ct_timestamp *ts;
+ if (!cpi->ct_active)
+ return NFCT_CB_STOP;
+
switch(type) {
case NFCT_T_UPDATE:
id = hashtable_hash(cpi->ct_active, ct);
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH ulogd2] nfct: fix counter-reset without hashtable
2025-03-25 0:24 [PATCH ulogd2] nfct: fix counter-reset without hashtable Corubba Smith
@ 2025-03-25 5:56 ` Florian Westphal
2025-03-25 9:20 ` Corubba Smith
0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2025-03-25 5:56 UTC (permalink / raw)
To: Corubba Smith; +Cc: netfilter-devel
Corubba Smith <corubba@gmx.de> wrote:
> The dump_reset_handler will try to update the hashtable regardless of
> whether it is used (and thus initialized), which results in a segfault
> if it isn't. Instead just short-circuit the handler, and skip any
> further result processing because it's not used in this case anyway.
> All flow counters in conntrack are reset regardless of the return value
> of the handler/callback.
How can this happen?
constructor_nfct (->start()) will return an error if ct_active table
cannot be allocated/is disabled?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH ulogd2] nfct: fix counter-reset without hashtable
2025-03-25 5:56 ` Florian Westphal
@ 2025-03-25 9:20 ` Corubba Smith
2025-03-25 10:35 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Corubba Smith @ 2025-03-25 9:20 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On 3/25/25 06:56, Florian Westphal wrote:
> Corubba Smith <corubba@gmx.de> wrote:
>> The dump_reset_handler will try to update the hashtable regardless of
>> whether it is used (and thus initialized), which results in a segfault
>> if it isn't. Instead just short-circuit the handler, and skip any
>> further result processing because it's not used in this case anyway.
>> All flow counters in conntrack are reset regardless of the return value
>> of the handler/callback.
>
> How can this happen?
> constructor_nfct (->start()) will return an error if ct_active table
> cannot be allocated/is disabled?
>
In event mode the hashtable is optional, and sending SIGUSR2 to ulogd will
call get_ctr_zero().
--
Corubba
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH ulogd2] nfct: fix counter-reset without hashtable
2025-03-25 9:20 ` Corubba Smith
@ 2025-03-25 10:35 ` Florian Westphal
0 siblings, 0 replies; 4+ messages in thread
From: Florian Westphal @ 2025-03-25 10:35 UTC (permalink / raw)
To: Corubba Smith; +Cc: Florian Westphal, netfilter-devel
Corubba Smith <corubba@gmx.de> wrote:
> On 3/25/25 06:56, Florian Westphal wrote:
> > Corubba Smith <corubba@gmx.de> wrote:
> >> The dump_reset_handler will try to update the hashtable regardless of
> >> whether it is used (and thus initialized), which results in a segfault
> >> if it isn't. Instead just short-circuit the handler, and skip any
> >> further result processing because it's not used in this case anyway.
> >> All flow counters in conntrack are reset regardless of the return value
> >> of the handler/callback.
> >
> > How can this happen?
> > constructor_nfct (->start()) will return an error if ct_active table
> > cannot be allocated/is disabled?
> >
>
> In event mode the hashtable is optional, and sending SIGUSR2 to ulogd will
> call get_ctr_zero().
Thanks, applied the patch with above sentence included in the commit
message.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-25 10:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 0:24 [PATCH ulogd2] nfct: fix counter-reset without hashtable Corubba Smith
2025-03-25 5:56 ` Florian Westphal
2025-03-25 9:20 ` Corubba Smith
2025-03-25 10:35 ` Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).