netfilter: updates for net
Subsystems (5)
Florian Westphal
maintainercover netfilter: updates for net
Hi,
The following patchset contains Netfilter fixes for *net*. These are fixes for bugs except patches 6 and 9 which fix issues added in last PR and 7.1-rc1.
1) Reject unsupported target families in xt_nat_checkentry(). From Wyatt Feng.
2) Fix inverted time_after() check in ecache_work_evict_list(). Causes pointless work rescheds and thus way longer time to clear the pending event backlog. From Yizhou Zhao.
3) Fix a use-after-free in br_ip6_fragment() caused by a dangling prevhdr pointer. From Xiang Mei.
4) Fix incorrect conntrack zone comparison in nf_conncount tuple deduplication. Pass IP_CT_DIR_ORIGINAL, not zone direction. From Yizhou Zhao.
5) Add bridge tunnel flowtable regression test for a bug that got fixed in the previous PR. From Zhengyang Chen.
6) Use the correct direction when setting up tunnel routes in the flowtable xmit path. From Pablo Neira Ayuso. This fixes a bug added in the previous PR.
7) Reload IP header after potential skb head reallocation in IPVS.
8) Fix incorrect IPv6 transport offsets in TCP application code. Correct the ICMPv6 header offset to ensure proper checksumming with extension headers, from Julian Anastasov. this is a followup to the previous PR.
9) Remove null-termination requirement for xt_physdev masks, this broke device names with 15 characters.
Please, pull these changes from:
The following changes since commit 4fa349156043dc119721d067329714179f501749:
net/iucv: take a reference on the socket found in afiucv_hs_rcv() (2026-07-10 16:24:43 +0200)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-26-07-10
for you to fetch changes up to f468c48d488d0ea2df3422b3e1dfafae1611e853:
netfilter: xt_physdev: masks are not c-strings (2026-07-10 16:28:47 +0200)
----------------------------------------------------------------
netfilter pull request nf-26-07-10
----------------------------------------------------------------
Florian Westphal (2):
ipvs: reload ip header after head reallocation
netfilter: xt_physdev: masks are not c-strings
Julian Anastasov (1):
ipvs: fix more places with wrong ipv6 transport offsets
Pablo Neira Ayuso (1):
netfilter: flowtable: use correct direction to set up tunnel route
Wyatt Feng (1):
netfilter: xt_nat: reject unsupported target families
Xiang Mei (Microsoft) (1):
netfilter: bridge: fix stale prevhdr pointer in br_ip6_fragment()
Yizhou Zhao (2):
netfilter: ecache: fix inverted time_after() check
netfilter: nf_conncount: fix zone comparison in tuple dedup
Zhengyang Chen (1):
selftests: netfilter: add bridge tunnel flowtable regression
net/ipv6/netfilter.c | 4 +- net/netfilter/ipvs/ip_vs_app.c | 10 ++-- net/netfilter/ipvs/ip_vs_core.c | 3 +- net/netfilter/ipvs/ip_vs_xmit.c | 6 +- net/netfilter/nf_conncount.c | 6 +- net/netfilter/nf_conntrack_ecache.c | 2 +- net/netfilter/nf_flow_table_core.c | 6 +- net/netfilter/xt_nat.c | 9 +++ net/netfilter/xt_physdev.c | 5 -- .../selftests/net/netfilter/nft_flowtable.sh | 55 +++++++++++++++++++ 10 files changed, 81 insertions(+), 25 deletions(-)
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 2/9 netfilter: ecache: fix inverted time_after() check
From: Yizhou Zhao <[email protected]>
ecache_work_evict_list() redelivers DESTROY events for conntracks that were moved to the per-netns dying_list after event delivery failed. It sets a 10ms deadline:
stop = jiffies + ECACHE_MAX_JIFFIES
but then tests:
time_after(stop, jiffies)
This condition is true while the deadline is still in the future, so the worker returns STATE_RESTART after the first successful redelivery in the usual case. ecache_work() maps STATE_RESTART to delay 0, which turns the redelivery path into one dying conntrack per workqueue dispatch and makes the sent > 16 batching/cond_resched() path effectively unreachable.
A conntrack netlink listener whose receive queue is congested can make DESTROY event delivery fail with -ENOBUFS. With sustained conntrack churn, entries then accumulate on the dying_list and are only drained at the degraded one-entry-per-dispatch rate once delivery succeeds again, wasting CPU on back-to-back workqueue reschedules and prolonging conntrack memory/resource pressure.
In a KASAN QEMU test with CONFIG_NF_CONNTRACK_EVENTS=y and nf_conntrack.enable_hooks=1, a congested DESTROY listener caused 8192 nf_ct_delete() calls to return false and move entries to the dying_list. After closing the listener, the unfixed kernel needed 7670 ecache_work() entries to destroy 7669 conntracks. With this change, the same 8192 entries were destroyed by 2 ecache_work() entries.
Swap the comparison so the worker restarts only after the deadline has expired.
--- net/netfilter/nf_conntrack_ecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_ecache.c +1 -1
@@ -77,7 +77,7 @@ static enum retry_state ecache_work_evict_list(struct nf_conntrack_net *cnet)hlist_nulls_del_rcu (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].hnnode);hlist_nulls_add_head (&ct->tuplehash[IP_CT_DIR_REPLY ].hnnode, &evicted_list); -if (time_after (stop, jiffies)) { +if (time_after (jiffies, stop)) { ret =STATE_RESTART ;break ; }
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 1/9 netfilter: xt_nat: reject unsupported target families
In reply to Florian WestphalFrom: Wyatt Feng <[email protected]>
xt_nat SNAT and DNAT target handlers assume IP-family conntrack state is present and can dereference a NULL pointer when instantiated from an unsupported family through nft_compat. A bridge-family compat rule can therefore trigger a NULL-dereference in nf_nat_setup_info().
Reject non-IP families in xt_nat_checkentry() so unsupported targets cannot be installed. Keep NFPROTO_INET allowed for valid inet NAT compat users and leave the runtime fast path unchanged.
[ The crash was fixed via
9dbba7e694ec ("netfilter: nft_compat: ebtables emulation must reject non-bridge targets"), so this patch is no longer critical.
Nevertheless, NAT is only relevant for ipv4/ipv6, so this extra
family check is a good idea in any case. ]
--- net/netfilter/xt_nat.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/netfilter/xt_nat.c +9 -0
@@ -26,6 +26,15 @@ static int xt_nat_checkentry_v0(const struct xt_tgchk_param *par)static int xt_nat_checkentry (const struct xt_tgchk_param *par) { +switch (par->family) { +case NFPROTO_IPV4 : +case NFPROTO_IPV6 : +case NFPROTO_INET : +break ; +default : +return -EINVAL ; + } +return nf_ct_netns_get (par->net, par->family); }
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 3/9 netfilter: bridge: fix stale prevhdr pointer in br_ip6_fragment()
In reply to Florian WestphalFrom: "Xiang Mei (Microsoft)" <[email protected]>
br_ip6_fragment() gets prevhdr, a pointer into the skb head, from ip6_find_1stfragopt(), then calls skb_checksum_help(). For a cloned skb skb_checksum_help() reallocates the head via pskb_expand_head(), leaving prevhdr dangling. It is later dereferenced in ip6_frag_next(), causing a use-after-free write.
Save prevhdr's offset before skb_checksum_help() and recompute it after, like commit ef0efcd3bd3f ("ipv6: Fix dangling pointer when ipv6 fragment").
BUG: KASAN: slab-use-after-free in ip6_frag_next (net/ipv6/ip6_output.c:857) Write of size 1 at addr ffff888013ff5016 by task exploit/141 Call Trace: ... kasan_report (mm/kasan/report.c:595) ip6_frag_next (net/ipv6/ip6_output.c:857) br_ip6_fragment (net/ipv6/netfilter.c:212) nf_ct_bridge_post (net/bridge/netfilter/nf_conntrack_bridge.c:407) nf_hook_slow (net/netfilter/core.c:619) br_forward_finish (net/bridge/br_forward.c:66) __br_forward (net/bridge/br_forward.c:115) maybe_deliver (net/bridge/br_forward.c:191) br_flood (net/bridge/br_forward.c:245) br_handle_frame_finish (net/bridge/br_input.c:229) br_handle_frame (net/bridge/br_input.c:442) ... packet_sendmsg (net/packet/af_packet.c:3114) ... do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception in interrupt
--- net/ipv6/netfilter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/netfilter.c +3 -1
@@ -120,7 +120,7 @@ int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,ktime_t tstamp = skb->tstamp;struct ip6_frag_state state;u8 *prevhdr, nexthdr =0 ; -unsigned int mtu, hlen; +unsigned int mtu, hlen, nexthdr_offset;int hroom, err =0 ;__be32 frag_id;
@@ -129,6 +129,7 @@ int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, goto blackhole; hlen = err; nexthdr = *prevhdr; + nexthdr_offset = prevhdr -skb_network_header (skb); mtu = skb->dev->mtu; if (frag_max_size > mtu ||
@@ -147,6 +148,7 @@ int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, (err = skb_checksum_help(skb))) goto blackhole; + prevhdr =skb_network_header (skb) + nexthdr_offset; hroom =LL_RESERVED_SPACE (skb->dev);if (skb_has_frag_list (skb)) {unsigned int first_len =skb_pagelen (skb);
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 4/9 netfilter: nf_conncount: fix zone comparison in tuple dedup
In reply to Florian WestphalFrom: Yizhou Zhao <[email protected]>
The "already exists" dedup logic in __nf_conncount_add() decides whether a connection has already been counted and can be skipped instead of incrementing the connlimit count. It compares the conntrack zone of a list entry with the zone of the connection being added using nf_ct_zone_id() and nf_ct_zone_equal(), passing conn->zone.dir or zone->dir as the direction argument.
Those helpers take enum ip_conntrack_dir values: IP_CT_DIR_ORIGINAL is 0 and IP_CT_DIR_REPLY is 1. However, zone->dir is a u8 bitmask:NF_CT_ZONE_DIR_ORIG is 1, NF_CT_ZONE_DIR_REPL is 2 and NF_CT_DEFAULT_ZONE_DIR is 3. Passing that bitmask as the enum direction shifts the meaning of every non-zero value. An ORIG-only zone passes 1 and is tested as REPLY, while REPL-only and default zones pass 2 or 3 and test bits beyond the valid direction range. In those cases nf_ct_zone_id() can fall back to NF_CT_DEFAULT_ZONE_ID instead of using the real zone id, so different zones can be treated as equal and dedup collapses to tuple equality alone.
nf_conncount stores and compares the original-direction tuple for a connection. If an skb already has an attached conntrack entry, get_ct_or_tuple_from_skb() explicitly copies ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, regardless of the packet's ctinfo. Therefore the zone comparison in the tuple dedup path must use IP_CT_DIR_ORIGINAL as well; the zone direction bitmask describes where a zone id applies, not which direction this conncount tuple represents.
Fix the two dedup comparisons by passing IP_CT_DIR_ORIGINAL directly. Do not special-case NF_CT_DEFAULT_ZONE_DIR and do not compare raw zone
ids: using the existing helpers with IP_CT_DIR_ORIGINAL preserves the direction-aware NF_CT_DEFAULT_ZONE_ID fallback. A default bidirectional zone contains the ORIG bit, so it naturally returns the real zone id; reply-only zones continue to fall back for original-direction tuple comparisons.
--- net/netfilter/nf_conncount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conncount.c +3 -3
@@ -211,8 +211,8 @@ static int __nf_conncount_add(struct net *net,/* Not found, but might be about to be confirmed */ if (PTR_ERR (found) == -EAGAIN ) {if (nf_ct_tuple_equal (&conn->tuple, &tuple) && -nf_ct_zone_id (&conn->zone, conn->zone.dir) == -nf_ct_zone_id (zone, zone->dir)) +nf_ct_zone_id (&conn->zone,IP_CT_DIR_ORIGINAL ) == +nf_ct_zone_id (zone,IP_CT_DIR_ORIGINAL )) goto out_put;/* already exists */ }else { collect++;
@@ -223,7 +223,7 @@ static int __nf_conncount_add(struct net *net, found_ct =nf_ct_tuplehash_to_ctrack (found);if (nf_ct_tuple_equal (&conn->tuple, &tuple) && -nf_ct_zone_equal (found_ct, zone, zone->dir)) { +nf_ct_zone_equal (found_ct, zone,IP_CT_DIR_ORIGINAL )) {/* * We should not see tuples twice unless someone hooks * this into a table without "-p tcp --syn".
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 5/9 selftests: netfilter: add bridge tunnel flowtable regression
In reply to Florian WestphalFrom: Zhengyang Chen <[email protected]>
Add a nft_flowtable.sh regression test for the bridge direct-xmit plus IPIP/IP6IP6 underlay configuration that reproduces the reachable DIRECT+tunnel tuple combination exercised by the flowtable fix.
The test reuses the existing bridge and tunnel topology, installs flow rules for the tunnel egress and bridge reply path, verifies IPv4 and IPv6 forwarding, and checks the flowtable counters after the transfer.
--- .../selftests/net/netfilter/nft_flowtable.sh | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+)
tools/testing/selftests/net/netfilter/nft_flowtable.sh +55 -0
@@ -736,6 +736,61 @@ if ! test_tcp_forwarding_nat "$ns1" "$ns2" 1 "on bridge"; then ret=1 fi +if ip -net "$nsr1" link show tun0 > /dev/null 2>&1 && + ip -net "$nsr2" link show tun0 > /dev/null 2>&1; then + ip -net "$nsr1" route change default via 192.168.100.2 + ip -net "$nsr2" route change default via 192.168.100.1 + ip -6 -net "$nsr1" route delete default + ip -6 -net "$nsr1" route add default via fee1:3::2 + ip -6 -net "$nsr2" route delete default + ip -6 -net "$nsr2" route add default via fee1:3::1 + ip -net "$ns2" route add default via 10.0.2.1 + ip -6 -net "$ns2" route add default via dead:2::1 + + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "tun0" tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept' + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "tun6" tcp dport 12345 ct mark set 1 flow add @f1 counter name routed_orig accept' + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "veth0" tcp sport 12345 ct mark set 1 flow add @f1 counter name routed_repl accept' + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "br0" tcp sport 12345 ct mark set 1 flow add @f1 counter name routed_repl accept' + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "tun0" accept' + ip netns exec "$nsr1" nft -a insert rule inet filter forward \ + 'meta oif "tun6" accept' + + ip netns exec "$nsr1" nft reset counters table inet filter >/dev/null + + if test_tcp_forwarding "$ns1" "$ns2" 1 4 10.0.2.99 12345; then + check_counters "bridge + IPIP tunnel" + else + echo "FAIL: flow offload for ns1/ns2 with bridge + IPIP tunnel" 1>&2 + ip netns exec "$nsr1" nft list ruleset + ret=1 + fi + + if test_tcp_forwarding "$ns1" "$ns2" 1 6 "[dead:2::99]" 12345; then + check_counters "bridge + IP6IP6 tunnel" + else + echo "FAIL: flow offload for ns1/ns2 with bridge + IP6IP6 tunnel" 1>&2 + ip netns exec "$nsr1" nft list ruleset + ret=1 + fi + + ip -net "$nsr1" route change default via 192.168.10.2 + ip -net "$nsr2" route change default via 192.168.10.1 + ip -net "$ns2" route del default via 10.0.2.1 + ip -6 -net "$nsr1" route delete default + ip -6 -net "$nsr1" route add default via fee1:2::2 + ip -6 -net "$nsr2" route delete default + ip -6 -net "$nsr2" route add default via fee1:2::1 + ip -6 -net "$ns2" route del default via dead:2::1 +else + echo "SKIP: bridge + tunnel flowtable regression (tun0 missing)" + [ "$ret" -eq 0 ] && ret=$ksft_skip +fi + # Another test: # Add bridge interface br0 to Router1, with NAT and VLAN.
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 6/9 netfilter: flowtable: use correct direction to set up tunnel route
In reply to Florian WestphalFrom: Pablo Neira Ayuso <[email protected]>
The layer 2 encapsulation and layer 3 tunnel information in the xmit path is taken from the other tuple, because the tunnel information that is included in the tuple for hashtable lookups is also used to perform the egress encapsulation in the transmit path.
This patch uses the correct direction when setting up the tunnel, the original proposed patch to address this fix uses the reversed direction.
While at it, remove the redundant check to call dst_release() to drop the reference on the dst that was obtained from the forward path, which is not useful in the direct xmit path unless tunneling is performed.
--- net/netfilter/nf_flow_table_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_core.c +3 -3
@@ -127,18 +127,18 @@ static int flow_offload_fill_route(struct flow_offload *flow,switch (route->tuple[dir].xmit_type) {case FLOW_OFFLOAD_XMIT_DIRECT : -if (flow_tuple->tun_num) { +if (route->tuple[!dir].in.num_tuns) { flow_tuple->dst_cache = dst; flow_tuple->dst_cookie =flow_offload_dst_cookie (flow_tuple); + }else { +dst_release (dst); }memcpy (flow_tuple->out.h_dest, route->tuple[dir].out.h_dest,ETH_ALEN );memcpy (flow_tuple->out.h_source, route->tuple[dir].out.h_source,ETH_ALEN ); flow_tuple->out.ifidx = route->tuple[dir].out.ifindex; -if (!flow_tuple->tun_num) -dst_release (dst);break ;case FLOW_OFFLOAD_XMIT_XFRM :case FLOW_OFFLOAD_XMIT_NEIGH :
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 7/9 ipvs: reload ip header after head reallocation
In reply to Florian Westphal__ip_vs_get_out_rt() calls skb_ensure_writable() which may reallocate skb->head.
--- net/netfilter/ipvs/ip_vs_xmit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_xmit.c +2 -4
@@ -736,13 +736,11 @@ int ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, struct ip_vs_iphdr *ipvsh) { - struct iphdr *iph = ip_hdr(skb); - -if (__ip_vs_get_out_rt (cp->ipvs, cp->af, skb,NULL , iph->daddr, + if (__ip_vs_get_out_rt(cp->ipvs, cp->af, skb, NULL, ip_hdr(skb)->daddr, IP_VS_RT_MODE_NON_LOCAL, NULL, ipvsh) < 0) goto tx_error; -ip_send_check (iph); +ip_send_check (ip_hdr(skb ));/* Another hack: avoid icmp_send in ip_fragment */ skb->ignore_df =1 ;
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 8/9 ipvs: fix more places with wrong ipv6 transport offsets
In reply to Florian WestphalFrom: Julian Anastasov <[email protected]>
Sashiko reports for more incorrect IPv6 transport offsets.
The app code for TCP was assuming IPv4 network header even after the ipvsh argument was provided. This can cause problems with apps over IPv6. As for the only official app in the kernel tree (FTP) this problem is harmless because we use Netfilter to mangle the FTP ports and we do not adjust the TCP seq numbers.
Also, provide correct offset of the ICMPV6 header in ip_vs_out_icmp_v6() for correct checksum checks when the IPv6 packet has extension headers.
--- net/netfilter/ipvs/ip_vs_app.c | 10 ++++------ net/netfilter/ipvs/ip_vs_core.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)
net/netfilter/ipvs/ip_vs_app.c +4 -6
@@ -361,14 +361,13 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, struct ip_vs_iphdr *ipvsh) {int diff; -const unsigned int tcp_offset =ip_hdrlen (skb);struct tcphdr *th;__u32 seq; -if (skb_ensure_writable (skb, tcp_offset +sizeof (*th))) +if (skb_ensure_writable (skb, ipvsh->len +sizeof (*th)))return 0 ; - th = (struct tcphdr *)(skb_network_header (skb) + tcp_offset); + th = (struct tcphdr *)(skb_network_header (skb) + ipvsh->len);/* * Remember seq number in case this pkt gets resized
@@ -438,14 +437,13 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff *skb, struct ip_vs_iphdr *ipvsh) {int diff; -const unsigned int tcp_offset =ip_hdrlen (skb);struct tcphdr *th;__u32 seq; -if (skb_ensure_writable (skb, tcp_offset +sizeof (*th))) +if (skb_ensure_writable (skb, ipvsh->len +sizeof (*th)))return 0 ; - th = (struct tcphdr *)(skb_network_header (skb) + tcp_offset); + th = (struct tcphdr *)(skb_network_header (skb) + ipvsh->len);/* * Remember seq number in case this pkt gets resized
net/netfilter/ipvs/ip_vs_core.c +1 -2
@@ -1219,8 +1219,7 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb, snet.in6 = ciph.saddr.in6; offset = ciph.len;return handle_response_icmp (AF_INET6 , skb, &snet, ciph.protocol, cp, - pp, offset,sizeof (struct ipv6hdr ), - hooknum); + pp, offset, ipvsh->len, hooknum); }#endif
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 9/9 netfilter: xt_physdev: masks are not c-strings
In reply to Florian Westphal... and must not be subjected to the 'nul terminated' constraint. If the interface name is 15 characters long, the mask is 16-bytes '0xff' (to cover for \0) and the valid device name is rejected.
--- net/netfilter/xt_physdev.c | 5 ----- 1 file changed, 5 deletions(-)
net/netfilter/xt_physdev.c +0 -5
@@ -130,11 +130,6 @@ static int physdev_mt_check(const struct xt_mtchk_param *par)if (X (physoutdev))return -ENAMETOOLONG ; } - -if (X (in_mask)) -return -ENAMETOOLONG ; -if (X (out_mask)) -return -ENAMETOOLONG ;#undef Xif (!brnf_probed) {
Signature · 1 line
2.54.0
Paolo Abeni
maintainerRe: [PATCH net 8/9] ipvs: fix more places with wrong ipv6 transport offsets
In reply to Florian WestphalHi,
Quoted 34 lines · Florian Westphal
From: Julian Anastasov <[email protected]>
Sashiko reports for more incorrect IPv6 transport offsets.
The app code for TCP was assuming IPv4 network header even after the ipvsh argument was provided. This can cause problems with apps over IPv6. As for the only official app in the kernel tree (FTP) this problem is harmless because we use Netfilter to mangle the FTP ports and we do not adjust the TCP seq numbers.
Also, provide correct offset of the ICMPV6 header in
ip_vs_out_icmp_v6()for correct checksum checks when the IPv6 packet has extension headers.Fixes d12e12299a69 ("ipvs: add ipv6 support to ftp")Fixes 2a3b791e6e11 ("IPVS: Add/adjust Netfilter hook functions and helpers for v6")Signed-off-by Julian Anastasov <[email protected]>Signed-off-by Florian Westphal <[email protected]>--- net/netfilter/ipvs/ip_vs_app.c | 10 ++++------ net/netfilter/ipvs/ip_vs_core.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)net/netfilter/ipvs/ip_vs_app.c +0
-0@@ -361,14 +361,13 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, struct ip_vs_iphdr *ipvsh) {int diff;
net/netfilter/ipvs/ip_vs_app.c static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, · line 370
Quoted 10 lines
net/netfilter/ipvs/ip_vs_app.c +2
-3-const unsigned int tcp_offset =ip_hdrlen (skb);struct tcphdr *th;__u32 seq; -if (skb_ensure_writable (skb, tcp_offset +sizeof (*th))) +if (skb_ensure_writable (skb, ipvsh->len +sizeof (*th)))return 0 ; - th = (struct tcphdr *)(skb_network_header (skb) + tcp_offset); + th = (struct tcphdr *)(skb_network_header (skb) + ipvsh->len);
Beyond the usual set of pre-existing issues, sashiko-gemini noted this patch may need a follow-up:
https://sashiko.dev/#/patchset/20260710143733.29741-2-fw%40strlen.de
/P
Re: [PATCH net 1/9] netfilter: xt_nat: reject unsupported target families
In reply to Florian WestphalThis series was applied to netdev/net.git (main) by Florian Westphal <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Florian Westphal <[email protected]>:
Quoted 8 lines · On Fri, 10 Jul 2026 16:37:25 +0200 you wrote:
From: Wyatt Feng <[email protected]>
xt_natSNAT and DNAT target handlers assume IP-family conntrack state is present and can dereference a NULL pointer when instantiated from an unsupported family throughnft_compat. A bridge-family compat rule can therefore trigger a NULL-dereference innf_nat_setup_info().[...]
Here is the summary with links:
- [net,1/9] netfilter: xt_nat: reject unsupported target families
https://git.kernel.org/netdev/net/c/5d1a2240935e - [net,2/9] netfilter: ecache: fix inverted time_after() check https://git.kernel.org/netdev/net/c/b06163ce52ec - [net,3/9] netfilter: bridge: fix stale prevhdr pointer in br_ip6_fragment() https://git.kernel.org/netdev/net/c/86f3ce81dd2b - [net,4/9] netfilter: nf_conncount: fix zone comparison in tuple dedup https://git.kernel.org/netdev/net/c/f62c41b4910e - [net,5/9] selftests: netfilter: add bridge tunnel flowtable regression https://git.kernel.org/netdev/net/c/bd0bdfae1cf0 - [net,6/9] netfilter: flowtable: use correct direction to set up tunnel route https://git.kernel.org/netdev/net/c/90941d9c925d - [net,7/9] ipvs: reload ip header after head reallocation https://git.kernel.org/netdev/net/c/a2f57827bf7c - [net,8/9] ipvs: fix more places with wrong ipv6 transport offsets https://git.kernel.org/netdev/net/c/b3fe4cbd5838 - [net,9/9] netfilter: xt_physdev: masks are not c-strings https://git.kernel.org/netdev/net/c/f468c48d488d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerRe: [PATCH net 8/9] ipvs: fix more places with wrong ipv6 transport offsets
In reply to Paolo AbeniHi,
Quoted 45 lines · Paolo Abeni
Hi,
Quoted 42 lines · Florian Westphal
From: Julian Anastasov <[email protected]>
Sashiko reports for more incorrect IPv6 transport offsets.
The app code for TCP was assuming IPv4 network header even after the ipvsh argument was provided. This can cause problems with apps over IPv6. As for the only official app in the kernel tree (FTP) this problem is harmless because we use Netfilter to mangle the FTP ports and we do not adjust the TCP seq numbers.
Also, provide correct offset of the ICMPV6 header in
ip_vs_out_icmp_v6()for correct checksum checks when the IPv6 packet has extension headers.Fixes d12e12299a69 ("ipvs: add ipv6 support to ftp")Fixes 2a3b791e6e11 ("IPVS: Add/adjust Netfilter hook functions and helpers for v6")Signed-off-by Julian Anastasov <[email protected]>Signed-off-by Florian Westphal <[email protected]>--- net/netfilter/ipvs/ip_vs_app.c | 10 ++++------ net/netfilter/ipvs/ip_vs_core.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)net/netfilter/ipvs/ip_vs_app.c +1
-2@@ -361,14 +361,13 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, struct ip_vs_iphdr *ipvsh) {int diff; -const unsigned int tcp_offset =ip_hdrlen (skb);struct tcphdr *th;__u32 seq; -if (skb_ensure_writable (skb, tcp_offset +sizeof (*th))) +if (skb_ensure_writable (skb, ipvsh->len +sizeof (*th)))return 0 ;
Quoted 7 lines
net/netfilter/ipvs/ip_vs_app.c static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, · line 370
Quoted 2 lines
net/netfilter/ipvs/ip_vs_app.c +1
-1- th = (struct tcphdr *)(skb_network_header (skb) + tcp_offset); + th = (struct tcphdr *)(skb_network_header (skb) + ipvsh->len);Beyond the usual set of pre-existing issues, sashiko-gemini noted this patch may need a follow-up:
https://sashiko.dev/#/patchset/20260710143733.29741-2-fw%40strlen.de
Cc'ing Julian, it seems he is not on Cc, in case he can help us with this.
Julian Anastasov
maintainerRe: [PATCH net 8/9] ipvs: fix more places with wrong ipv6 transport offsets
In reply to Paolo AbeniHello,
Quoted 45 lines · Paolo Abeni
Hi,
Quoted 42 lines · Florian Westphal
From: Julian Anastasov <[email protected]>
Sashiko reports for more incorrect IPv6 transport offsets.
The app code for TCP was assuming IPv4 network header even after the ipvsh argument was provided. This can cause problems with apps over IPv6. As for the only official app in the kernel tree (FTP) this problem is harmless because we use Netfilter to mangle the FTP ports and we do not adjust the TCP seq numbers.
Also, provide correct offset of the ICMPV6 header in
ip_vs_out_icmp_v6()for correct checksum checks when the IPv6 packet has extension headers.Fixes d12e12299a69 ("ipvs: add ipv6 support to ftp")Fixes 2a3b791e6e11 ("IPVS: Add/adjust Netfilter hook functions and helpers for v6")Signed-off-by Julian Anastasov <[email protected]>Signed-off-by Florian Westphal <[email protected]>--- net/netfilter/ipvs/ip_vs_app.c | 10 ++++------ net/netfilter/ipvs/ip_vs_core.c | 3 +-- 2 files changed, 5 insertions(+), 8 deletions(-)net/netfilter/ipvs/ip_vs_app.c +1
-2@@ -361,14 +361,13 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, struct ip_vs_iphdr *ipvsh) {int diff; -const unsigned int tcp_offset =ip_hdrlen (skb);struct tcphdr *th;__u32 seq; -if (skb_ensure_writable (skb, tcp_offset +sizeof (*th))) +if (skb_ensure_writable (skb, ipvsh->len +sizeof (*th)))return 0 ;
Quoted 7 lines
net/netfilter/ipvs/ip_vs_app.c static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff *skb, · line 370
Quoted 2 lines
net/netfilter/ipvs/ip_vs_app.c +1
-1- th = (struct tcphdr *)(skb_network_header (skb) + tcp_offset); + th = (struct tcphdr *)(skb_network_header (skb) + ipvsh->len);Beyond the usual set of pre-existing issues, sashiko-gemini noted this patch may need a follow-up:
https://sashiko.dev/#/patchset/20260710143733.29741-2-fw%40strlen.de
I'll provide fix to continue supporting non-zero
network offset but I already don't remember what is the use case. As for the handle_response_icmp() checksum validation problem I'm still working on the patch.
Regards
--
Julian Anastasov <[email protected]>