* [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core
@ 2026-05-26 14:18 Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 1/5 nf-next v3] netfilter: synproxy: drop packets if timestamp adjustment fails Fernando Fernandez Mancera
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
This series fixes several long standing issues during synproxy timestamp
adjustment and concurrent hook registration. From ignored error handling
to unaligned memory access. Most of this are not issues impacting real
setups as they would have been reported before.
FWIW; I am sending these fixes as separated patches because they are
addressing independent issues.
Fernando Fernandez Mancera (5):
netfilter: synproxy: drop packets if timestamp adjustment fails
netfilter: synproxy: adjust duplicate timestamp options
netfilter: synproxy: fix unaligned memory access in timestamp
adjustment
netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock
netfilter: synproxy: add mutex to guard hook reference counting
net/netfilter/nf_synproxy_core.c | 76 +++++++++++++++++++++-----------
1 file changed, 51 insertions(+), 25 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5 nf-next v3] netfilter: synproxy: drop packets if timestamp adjustment fails
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
@ 2026-05-26 14:18 ` Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 2/5 nf-next v3] netfilter: synproxy: adjust duplicate timestamp options Fernando Fernandez Mancera
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
If a packet was malformed or if skb_ensure_writable() failed, the
synproxy_tstamp_adjust() function returned 0 indicating an error but it
was ignored on the callers.
Make the function return a boolean instead to clarify the result and
drop the packet if synproxy_tstamp_adjust() failed due to ENOMEM from
skb_ensure_writable(). In addition, if there are malformed options, skip
the tstamp update but do not drop the packet as that should be done by
the policy directly.
Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
net/netfilter/nf_synproxy_core.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index 57f57e2fc80a..e523b64bf839 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -182,7 +182,7 @@ synproxy_check_timestamp_cookie(struct synproxy_options *opts)
opts->options |= opts->tsecr & (1 << 5) ? NF_SYNPROXY_OPT_ECN : 0;
}
-static unsigned int
+static bool
synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
struct tcphdr *th, struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
@@ -192,20 +192,20 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
__be32 *ptr, old;
if (synproxy->tsoff == 0)
- return 1;
+ return true;
optoff = protoff + sizeof(struct tcphdr);
optend = protoff + th->doff * 4;
if (skb_ensure_writable(skb, optend))
- return 0;
+ return false;
while (optoff < optend) {
unsigned char *op = skb->data + optoff;
switch (op[0]) {
case TCPOPT_EOL:
- return 1;
+ return true;
case TCPOPT_NOP:
optoff++;
continue;
@@ -213,7 +213,7 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
if (optoff + 1 == optend ||
optoff + op[1] > optend ||
op[1] < 2)
- return 0;
+ return true;
if (op[0] == TCPOPT_TIMESTAMP &&
op[1] == TCPOLEN_TIMESTAMP) {
if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
@@ -229,12 +229,12 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
}
inet_proto_csum_replace4(&th->check, skb,
old, *ptr, false);
- return 1;
+ return true;
}
optoff += op[1];
}
}
- return 1;
+ return true;
}
#ifdef CONFIG_PROC_FS
@@ -745,7 +745,9 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
break;
}
- synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy);
+ if (!synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy))
+ return NF_DROP_REASON(skb, SKB_DROP_REASON_NETFILTER_DROP, ENOMEM);
+
return NF_ACCEPT;
}
EXPORT_SYMBOL_GPL(ipv4_synproxy_hook);
@@ -1168,7 +1170,9 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
break;
}
- synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy);
+ if (!synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy))
+ return NF_DROP_REASON(skb, SKB_DROP_REASON_NETFILTER_DROP, ENOMEM);
+
return NF_ACCEPT;
}
EXPORT_SYMBOL_GPL(ipv6_synproxy_hook);
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5 nf-next v3] netfilter: synproxy: adjust duplicate timestamp options
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 1/5 nf-next v3] netfilter: synproxy: drop packets if timestamp adjustment fails Fernando Fernandez Mancera
@ 2026-05-26 14:18 ` Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 3/5 nf-next v3] netfilter: synproxy: fix unaligned memory access in timestamp adjustment Fernando Fernandez Mancera
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
RFC 9293 does not mention anything about duplicated options and each
networking stack handles it in their own way. Currently, Linux kernel is
processing options sequentially and in case of duplicated timestamp
options, the value from the latest one overrides the others.
As SYNPROXY is modifying only the first timestamp option found, a packet
can reach the backend server and it might parse the wrong timestamp
value. Let's just continue parsing the following options and in case a
duplicated timestamp is found, adjust it too.
Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
net/netfilter/nf_synproxy_core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index e523b64bf839..6bd63f5ab75d 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -229,7 +229,6 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
}
inet_proto_csum_replace4(&th->check, skb,
old, *ptr, false);
- return true;
}
optoff += op[1];
}
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5 nf-next v3] netfilter: synproxy: fix unaligned memory access in timestamp adjustment
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 1/5 nf-next v3] netfilter: synproxy: drop packets if timestamp adjustment fails Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 2/5 nf-next v3] netfilter: synproxy: adjust duplicate timestamp options Fernando Fernandez Mancera
@ 2026-05-26 14:18 ` Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 5/5 nf-next v3] netfilter: synproxy: add mutex to guard hook reference counting Fernando Fernandez Mancera
4 siblings, 0 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
Use get_unaligned_be32() and put_unaligned_be32() to safely read and
write the timestamp fields. This prevents performance degradation due to
unaligned memory access or even a crash on strict alignment
architectures.
This follows the implementation of timestamp parsing in the networking
stack at tcp_parse_options() and synproxy_parse_options().
Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
net/netfilter/nf_synproxy_core.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index 6bd63f5ab75d..5413133a42fa 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -189,7 +189,7 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
const struct nf_conn_synproxy *synproxy)
{
unsigned int optoff, optend;
- __be32 *ptr, old;
+ u32 new, old;
if (synproxy->tsoff == 0)
return true;
@@ -217,18 +217,17 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,
if (op[0] == TCPOPT_TIMESTAMP &&
op[1] == TCPOLEN_TIMESTAMP) {
if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
- ptr = (__be32 *)&op[2];
- old = *ptr;
- *ptr = htonl(ntohl(*ptr) -
- synproxy->tsoff);
+ old = get_unaligned_be32(&op[2]);
+ new = old - synproxy->tsoff;
+ put_unaligned_be32(new, &op[2]);
} else {
- ptr = (__be32 *)&op[6];
- old = *ptr;
- *ptr = htonl(ntohl(*ptr) +
- synproxy->tsoff);
+ old = get_unaligned_be32(&op[6]);
+ new = old + synproxy->tsoff;
+ put_unaligned_be32(new, &op[6]);
}
inet_proto_csum_replace4(&th->check, skb,
- old, *ptr, false);
+ cpu_to_be32(old),
+ cpu_to_be32(new), false);
}
optoff += op[1];
}
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
` (2 preceding siblings ...)
2026-05-26 14:18 ` [PATCH 3/5 nf-next v3] netfilter: synproxy: fix unaligned memory access in timestamp adjustment Fernando Fernandez Mancera
@ 2026-05-26 14:18 ` Fernando Fernandez Mancera
2026-05-26 14:59 ` Pablo Neira Ayuso
2026-05-26 14:18 ` [PATCH 5/5 nf-next v3] netfilter: synproxy: add mutex to guard hook reference counting Fernando Fernandez Mancera
4 siblings, 1 reply; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
nf_ct_seqadj_init() is called without holding the ct lock. This can race
with nf_ct_seq_adjust() when a connection is in CLOSE state due to an
RST or connection reopening. In addition for SYN_RECV state, concurrent
processing of packets can trigger nf_ct_seq_adjust() too. These
situations create a read/write data race.
Fix this by wrapping the nf_ct_seqadj_init() calls in the synproxy hooks
with locking.
Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
net/netfilter/nf_synproxy_core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index 5413133a42fa..3e02e252eecc 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -669,8 +669,10 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
switch (state->state) {
case TCP_CONNTRACK_CLOSE:
if (th->rst && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
ntohl(th->seq) + 1);
+ spin_unlock_bh(&ct->lock);
break;
}
@@ -682,7 +684,9 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
* adjustments, they will get initialized once the connection is
* reestablished.
*/
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, 0);
+ spin_unlock_bh(&ct->lock);
synproxy->tsoff = 0;
this_cpu_inc(snet->stats->conn_reopened);
fallthrough;
@@ -731,7 +735,9 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
swap(opts.tsval, opts.tsecr);
synproxy_send_server_ack(net, state, skb, th, &opts);
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
+ spin_unlock_bh(&ct->lock);
nf_conntrack_event_cache(IPCT_SEQADJ, ct);
swap(opts.tsval, opts.tsecr);
@@ -1094,8 +1100,10 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
switch (state->state) {
case TCP_CONNTRACK_CLOSE:
if (th->rst && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
ntohl(th->seq) + 1);
+ spin_unlock_bh(&ct->lock);
break;
}
@@ -1107,7 +1115,9 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
* adjustments, they will get initialized once the connection is
* reestablished.
*/
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, 0);
+ spin_unlock_bh(&ct->lock);
synproxy->tsoff = 0;
this_cpu_inc(snet->stats->conn_reopened);
fallthrough;
@@ -1156,7 +1166,9 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
swap(opts.tsval, opts.tsecr);
synproxy_send_server_ack_ipv6(net, state, skb, th, &opts);
+ spin_lock_bh(&ct->lock);
nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
+ spin_unlock_bh(&ct->lock);
nf_conntrack_event_cache(IPCT_SEQADJ, ct);
swap(opts.tsval, opts.tsecr);
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5 nf-next v3] netfilter: synproxy: add mutex to guard hook reference counting
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
` (3 preceding siblings ...)
2026-05-26 14:18 ` [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock Fernando Fernandez Mancera
@ 2026-05-26 14:18 ` Fernando Fernandez Mancera
4 siblings, 0 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 14:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera
As the synproxy infrastructure register netfilter hooks on-demand when a
user adds the first iptables target or nftables expression, if done
concurrently they can race each other.
Introduce a mutex to serialize the refcount control blocks access from
both frontends. While a per namespace mutex might be more efficient, it
is not needed for target/expression like SYNPROXY.
Fixes: ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
net/netfilter/nf_synproxy_core.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index 3e02e252eecc..6745c09a2a6f 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -22,6 +22,8 @@
#include <net/netfilter/nf_conntrack_zones.h>
#include <net/netfilter/nf_synproxy.h>
+static DEFINE_MUTEX(synproxy_mutex);
+
unsigned int synproxy_net_id;
EXPORT_SYMBOL_GPL(synproxy_net_id);
@@ -773,26 +775,31 @@ static const struct nf_hook_ops ipv4_synproxy_ops[] = {
int nf_synproxy_ipv4_init(struct synproxy_net *snet, struct net *net)
{
- int err;
+ int err = 0;
+ mutex_lock(&synproxy_mutex);
if (snet->hook_ref4 == 0) {
err = nf_register_net_hooks(net, ipv4_synproxy_ops,
ARRAY_SIZE(ipv4_synproxy_ops));
if (err)
- return err;
+ goto out;
}
snet->hook_ref4++;
- return 0;
+out:
+ mutex_unlock(&synproxy_mutex);
+ return err;
}
EXPORT_SYMBOL_GPL(nf_synproxy_ipv4_init);
void nf_synproxy_ipv4_fini(struct synproxy_net *snet, struct net *net)
{
+ mutex_lock(&synproxy_mutex);
snet->hook_ref4--;
if (snet->hook_ref4 == 0)
nf_unregister_net_hooks(net, ipv4_synproxy_ops,
ARRAY_SIZE(ipv4_synproxy_ops));
+ mutex_unlock(&synproxy_mutex);
}
EXPORT_SYMBOL_GPL(nf_synproxy_ipv4_fini);
@@ -1205,27 +1212,32 @@ static const struct nf_hook_ops ipv6_synproxy_ops[] = {
int
nf_synproxy_ipv6_init(struct synproxy_net *snet, struct net *net)
{
- int err;
+ int err = 0;
+ mutex_lock(&synproxy_mutex);
if (snet->hook_ref6 == 0) {
err = nf_register_net_hooks(net, ipv6_synproxy_ops,
ARRAY_SIZE(ipv6_synproxy_ops));
if (err)
- return err;
+ goto out;
}
snet->hook_ref6++;
- return 0;
+out:
+ mutex_unlock(&synproxy_mutex);
+ return err;
}
EXPORT_SYMBOL_GPL(nf_synproxy_ipv6_init);
void
nf_synproxy_ipv6_fini(struct synproxy_net *snet, struct net *net)
{
+ mutex_lock(&synproxy_mutex);
snet->hook_ref6--;
if (snet->hook_ref6 == 0)
nf_unregister_net_hooks(net, ipv6_synproxy_ops,
ARRAY_SIZE(ipv6_synproxy_ops));
+ mutex_unlock(&synproxy_mutex);
}
EXPORT_SYMBOL_GPL(nf_synproxy_ipv6_fini);
#endif /* CONFIG_IPV6 */
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock
2026-05-26 14:18 ` [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock Fernando Fernandez Mancera
@ 2026-05-26 14:59 ` Pablo Neira Ayuso
2026-05-26 21:18 ` Fernando Fernandez Mancera
0 siblings, 1 reply; 8+ messages in thread
From: Pablo Neira Ayuso @ 2026-05-26 14:59 UTC (permalink / raw)
To: Fernando Fernandez Mancera; +Cc: netfilter-devel, coreteam, fw, phil
Hi Fernando,
linux$ git grep nf_ct_seqadj_init
net/netfilter/nf_conntrack_seqadj.c:int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
net/netfilter/nf_conntrack_seqadj.c:EXPORT_SYMBOL_GPL(nf_ct_seqadj_init);
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, 0);
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, 0);
net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
On Tue, May 26, 2026 at 04:18:37PM +0200, Fernando Fernandez Mancera wrote:
> diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
> index 5413133a42fa..3e02e252eecc 100644
> --- a/net/netfilter/nf_synproxy_core.c
> +++ b/net/netfilter/nf_synproxy_core.c
> @@ -669,8 +669,10 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
> switch (state->state) {
> case TCP_CONNTRACK_CLOSE:
> if (th->rst && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
> + spin_lock_bh(&ct->lock);
> nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
> ntohl(th->seq) + 1);
> + spin_unlock_bh(&ct->lock);
> break;
Maybe add the spin_lock to nf_ct_seqadj_init() given synproxy is the
only user of this function?
> }
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock
2026-05-26 14:59 ` Pablo Neira Ayuso
@ 2026-05-26 21:18 ` Fernando Fernandez Mancera
0 siblings, 0 replies; 8+ messages in thread
From: Fernando Fernandez Mancera @ 2026-05-26 21:18 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, coreteam, fw, phil
On 5/26/26 4:59 PM, Pablo Neira Ayuso wrote:
> Hi Fernando,
>
> linux$ git grep nf_ct_seqadj_init
> net/netfilter/nf_conntrack_seqadj.c:int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
> net/netfilter/nf_conntrack_seqadj.c:EXPORT_SYMBOL_GPL(nf_ct_seqadj_init);
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, 0);
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, 0);
> net/netfilter/nf_synproxy_core.c: nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
>
> On Tue, May 26, 2026 at 04:18:37PM +0200, Fernando Fernandez Mancera wrote:
>> diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
>> index 5413133a42fa..3e02e252eecc 100644
>> --- a/net/netfilter/nf_synproxy_core.c
>> +++ b/net/netfilter/nf_synproxy_core.c
>> @@ -669,8 +669,10 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
>> switch (state->state) {
>> case TCP_CONNTRACK_CLOSE:
>> if (th->rst && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
>> + spin_lock_bh(&ct->lock);
>> nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
>> ntohl(th->seq) + 1);
>> + spin_unlock_bh(&ct->lock);
>> break;
>
> Maybe add the spin_lock to nf_ct_seqadj_init() given synproxy is the
> only user of this function?
>
Thanks Pablo, makes a lot of sense.
>> }
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-05-26 21:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 14:18 [PATCH 0/5 nf-next v3] netfilter: synproxy: misc fixes about synproxy core Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 1/5 nf-next v3] netfilter: synproxy: drop packets if timestamp adjustment fails Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 2/5 nf-next v3] netfilter: synproxy: adjust duplicate timestamp options Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 3/5 nf-next v3] netfilter: synproxy: fix unaligned memory access in timestamp adjustment Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 4/5 nf-next v3] netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock Fernando Fernandez Mancera
2026-05-26 14:59 ` Pablo Neira Ayuso
2026-05-26 21:18 ` Fernando Fernandez Mancera
2026-05-26 14:18 ` [PATCH 5/5 nf-next v3] netfilter: synproxy: add mutex to guard hook reference counting Fernando Fernandez Mancera
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.