linux/include
Pablo Neira Ayuso b8b09dc2bf netfilter: nf_conntrack_expect: use conntrack GC to reap expectations
This patch replaces the timer API by GC worker approach for
expectations, as it already happened in many other subsystems.

Use the existing conntrack GC worker to iterate over the local list of
expectations in the master conntrack to reap expired expectations.
Check IPS_HELPER_BIT to run GC for expectations, set it on for nft_ct
expectation which nevers sets it. Hold the expectation spinlock while
iterating over the master conntrack expectation list to synchronize with
nf_ct_remove_expectations(). This also performs runtime packet path
garbage collection through the expectation insertion and lookup
functions while walking over one of the chains of the global expectation
hashtables. Unconfirmed conntrack entries are skipped since ct->ext can
be reallocated and dying are skipped since those will be gone soon.
Set on IPS_HELPER_BIT if the helper ct extension is added, then the new
GC worker does not need to bump the ct refcount to check if the ct->ext
helper is available.

This removes the extra bump on the refcount for expectation timers, this
allows to remove several nf_ct_expect_put() calls after the unlink,
after this update only refcount remains at 1 while on the expectation
hashes.

This patch implicitly addresses a race with the existing timer API
allowing an expectation to access a stale exp->master pointer which has
been already released when expectation removal loses races with an
expiring timer, ie. timer_del() reporting false.

Add a new NF_CT_EXPECT_DEAD flag to reap this expectation via GC. This
is needed by nf_conntrack_unexpect_related() which is called in error
paths to invalidate newly created expectations that has been added into
the hashes. These expectactions cannot be inmediately released as GC or
nf_ct_remove_expectations() could race to make it. On expectation
insert, the runtime GC reaps stale expectations before checking the
expectation limit set by policy.

Set current timestamp in nf_ct_expect_alloc(), then add the expectation
policy timeout (or custom timeout specified added on top of this) to
specify the expectation lifetime.

Fixes: bffcaad9af ("netfilter: ctnetlink: ensure safe access to master conntrack")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2026-06-21 00:18:27 +02:00
..
acpi Driver core changes for 7.2-rc1 2026-06-15 12:41:17 +05:30
asm-generic Locking updates for v7.2: 2026-06-15 14:21:14 +05:30
clocksource
crypto Networking changes for 7.2. 2026-06-17 08:17:00 +01:00
cxl
drm Short summary of fixes pull: 2026-06-13 07:52:40 +10:00
dt-bindings dt-bindings: gpio: meson-axg: Fix whitespace issue 2026-05-26 10:02:53 +02:00
hyperv hyperv: Clean up and fix the guest ID comment in hvgdk.h 2026-05-27 15:05:26 -07:00
keys
kunit linux_kselftest-kunit-7.2-rc1 2026-06-16 16:33:57 +05:30
kvm
linux Networking changes for 7.2. 2026-06-17 08:17:00 +01:00
math-emu
media
memory
misc
net netfilter: nf_conntrack_expect: use conntrack GC to reap expectations 2026-06-21 00:18:27 +02:00
pcmcia
ras
rdma RDMA: During rereg_mr ensure that REREG_ACCESS is compatible 2026-06-08 13:39:20 -03:00
rv rv: Prevent task migration while handling per-CPU events 2026-06-03 12:33:25 +02:00
scsi
soc Networking changes for 7.2. 2026-06-17 08:17:00 +01:00
sound
target
trace Networking changes for 7.2. 2026-06-17 08:17:00 +01:00
uapi netfilter: nf_conntrack_expect: use conntrack GC to reap expectations 2026-06-21 00:18:27 +02:00
ufs
vdso futex: Provide infrastructure to plug the non contended robust futex unlock race 2026-06-03 11:38:52 +02:00
video
xen xen: constify xsd_errors array 2026-06-08 09:00:06 +02:00
Kbuild