Netfilter fixes for net
Subsystems (5)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi,
The following patchset contains Netfilter fixes for net:
1) Fix bogus compilter warning in nfnetlink_queue, from Florian Westphal.
2) Don't run conntrack on vrf with !dflt qdisc, from Nicolas Dichtel.
3) Fix nft_pipapo bucket load in AVX2 lookup routine for six 8-bit groups, from Stefano Brivio.
4) Break rule evaluation on malformed TCP options.
5) Use socat instead of nc in selftests/netfilter/nft_zones_many.sh, also from Florian
6) Fix KCSAN data-race in conntrack timeout updates, from Eric Dumazet.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 34d8778a943761121f391b7921f79a7adbe1feaf:
MAINTAINERS: s390/net: add Alexandra and Wenjia as maintainer (2021-11-30 12:20:07 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 802a7dc5cf1bef06f7b290ce76d478138408d6b1:
netfilter: conntrack: annotate data-races around ct->timeout (2021-12-08 01:29:15 +0100)
----------------------------------------------------------------
Eric Dumazet (1):
netfilter: conntrack: annotate data-races around ct->timeout
Florian Westphal (2):
netfilter: nfnetlink_queue: silence bogus compiler warning
selftests: netfilter: switch zone stress to socat
Nicolas Dichtel (1):
vrf: don't run conntrack on vrf with !dflt qdisc
Pablo Neira Ayuso (1):
netfilter: nft_exthdr: break evaluation if setting TCP option fails
Stefano Brivio (2):
nft_set_pipapo: Fix bucket load in AVX2 lookup routine for six 8-bit groups
selftests: netfilter: Add correctness test for mac,net set type
drivers/net/vrf.c | 8 +++--- include/net/netfilter/nf_conntrack.h | 6 ++--- net/netfilter/nf_conntrack_core.c | 6 ++--- net/netfilter/nf_conntrack_netlink.c | 2 +- net/netfilter/nf_flow_table_core.c | 4 +-- net/netfilter/nfnetlink_queue.c | 2 +- net/netfilter/nft_exthdr.c | 11 +++++--- net/netfilter/nft_set_pipapo_avx2.c | 2 +- tools/testing/selftests/netfilter/conntrack_vrf.sh | 30 +++++++++++++++++++--- .../selftests/netfilter/nft_concat_range.sh | 24 ++++++++++++++--- .../testing/selftests/netfilter/nft_zones_many.sh | 19 +++++++++----- 11 files changed, 82 insertions(+), 32 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/7 netfilter: nfnetlink_queue: silence bogus compiler warning
From: Florian Westphal <[email protected]>
net/netfilter/nfnetlink_queue.c:601:36: warning: variable 'ctinfo' is uninitialized when used here [-Wuninitialized]
if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
ctinfo is only uninitialized if ct == NULL. Init it to 0 to silence this.
--- net/netfilter/nfnetlink_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_queue.c +1 -1
@@ -387,7 +387,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,struct net_device *indev;struct net_device *outdev;struct nf_conn *ct =NULL ; -enum ip_conntrack_info ctinfo; +enum ip_conntrack_info ctinfo =0 ;struct nfnl_ct_hook *nfnl_ct;bool csum_verify;char *secdata =NULL ;
Signature · 1 line
2.30.2
Re: [PATCH net 1/7] netfilter: nfnetlink_queue: silence bogus compiler warning
This series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Quoted 9 lines · On Thu, 9 Dec 2021 01:08:41 +0100 you wrote:
From: Florian Westphal <[email protected]>
net/netfilter/nfnetlink_queue.c:601:36: warning: variable 'ctinfo' is uninitialized when used here [-Wuninitialized]
if (ct &&nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO)< 0)ctinfo is only uninitialized if ct == NULL. Init it to 0 to silence this.
[...]
Here is the summary with links:
- [net,1/7] netfilter: nfnetlink_queue: silence bogus compiler warning
https://git.kernel.org/netdev/net/c/b43c2793f5e9 - [net,2/7] vrf: don't run conntrack on vrf with !dflt qdisc https://git.kernel.org/netdev/net/c/d43b75fbc23f - [net,3/7] nft_set_pipapo: Fix bucket load in AVX2 lookup routine for six 8-bit groups https://git.kernel.org/netdev/net/c/b7e945e228d7 - [net,4/7] selftests: netfilter: Add correctness test for mac,net set type https://git.kernel.org/netdev/net/c/0de53b0ffb5b - [net,5/7] netfilter: nft_exthdr: break evaluation if setting TCP option fails https://git.kernel.org/netdev/net/c/962e5a403587 - [net,6/7] selftests: netfilter: switch zone stress to socat https://git.kernel.org/netdev/net/c/d46cea0e6933 - [net,7/7] netfilter: conntrack: annotate data-races around ct->timeout https://git.kernel.org/netdev/net/c/802a7dc5cf1b
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
maintainerPATCH 2/7 vrf: don't run conntrack on vrf with !dflt qdisc
In reply to Pablo Neira AyusoFrom: Nicolas Dichtel <[email protected]>
After the below patch, the conntrack attached to skb is set to "notrack" in the context of vrf device, for locally generated packets.
But this is true only when the default qdisc is set to the vrf device. When changing the qdisc, notrack is not set anymore.
In fact, there is a shortcut in the vrf driver, when the default qdisc is set, see commit dcdd43c41e60 ("net: vrf: performance improvements for IPv4") for more details.
This patch ensures that the behavior is always the same, whatever the qdisc is.
To demonstrate the difference, a new test is added in conntrack_vrf.sh.
--- drivers/net/vrf.c | 8 ++--- .../selftests/netfilter/conntrack_vrf.sh | 30 ++++++++++++++++--- 2 files changed, 30 insertions(+), 8 deletions(-)
drivers/net/vrf.c +4 -4
@@ -768,8 +768,6 @@ static struct sk_buff *vrf_ip6_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; -vrf_nf_set_untracked (skb); - err =nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip6_out_direct_finish);
@@ -790,6 +788,8 @@ static struct sk_buff *vrf_ip6_out(struct net_device *vrf_dev,if (rt6_need_strict (&ipv6_hdr (skb)->daddr))return skb; +vrf_nf_set_untracked (skb); +if (qdisc_tx_is_default (vrf_dev) ||IP6CB (skb)->flags &IP6SKB_XFRM_TRANSFORMED )return vrf_ip6_out_direct (vrf_dev, sk, skb);
@@ -998,8 +998,6 @@ static struct sk_buff *vrf_ip_out_direct(struct net_device *vrf_dev, skb->dev = vrf_dev; -vrf_nf_set_untracked (skb); - err =nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , net, sk, skb,NULL , vrf_dev, vrf_ip_out_direct_finish);
@@ -1021,6 +1019,8 @@ static struct sk_buff *vrf_ip_out(struct net_device *vrf_dev, ipv4_is_lbcast(ip_hdr(skb)->daddr))return skb; +vrf_nf_set_untracked (skb); +if (qdisc_tx_is_default (vrf_dev) ||IPCB (skb)->flags &IPSKB_XFRM_TRANSFORMED )return vrf_ip_out_direct (vrf_dev, sk, skb);
tools/testing/selftests/netfilter/conntrack_vrf.sh +26 -4
@@ -150,11 +150,27 @@ EOF # oifname is the vrf device. test_masquerade_vrf() { + local qdisc=$1 + + if [ "$qdisc" != "default" ]; then + tc -net $ns0 qdisc add dev tvrf root $qdisc + fi + ip netns exec $ns0 conntrack -F 2>/dev/null ip netns exec $ns0 nft -f - <<EOF flush ruleset table ip nat { + chain rawout { + type filter hook output priority raw; + + oif tvrf ct state untracked counter + } + chain postrouting2 { + type filter hook postrouting priority mangle; + + oif tvrf ct state untracked counter + } chain postrouting { type nat hook postrouting priority 0; # NB: masquerade should always be combined with 'oif(name) bla',
@@ -171,13 +187,18 @@ EOF fi # must also check that nat table was evaluated on second (lower device) iteration. - ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' + ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' && + ip netns exec $ns0 nft list table ip nat |grep -q 'untracked counter packets [1-9]' if [ $? -eq 0 ]; then - echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device" + echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)" else - echo "FAIL: vrf masq rule has unexpected counter value" + echo "FAIL: vrf rules have unexpected counter value" ret=1 fi + + if [ "$qdisc" != "default" ]; then + tc -net $ns0 qdisc del dev tvrf root + fi } # add masq rule that gets evaluated w. outif set to veth device.
@@ -213,7 +234,8 @@ EOF } test_ct_zone_in -test_masquerade_vrf +test_masquerade_vrf "default" +test_masquerade_vrf "pfifo" test_masquerade_veth exit $ret
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 3/7 nft_set_pipapo: Fix bucket load in AVX2 lookup routine for six 8-bit groups
In reply to Pablo Neira AyusoFrom: Stefano Brivio <[email protected]>
The sixth byte of packet data has to be looked up in the sixth group, not in the seventh one, even if we load the bucket data into ymm6 (and not ymm5, for convenience of tracking stalls).
Without this fix, matching on a MAC address as first field of a set, if 8-bit groups are selected (due to a small set size) would fail, that is, the given MAC address would never match.
--- net/netfilter/nft_set_pipapo_avx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_set_pipapo_avx2.c +1 -1
@@ -886,7 +886,7 @@ static int nft_pipapo_avx2_lookup_8b_6(unsigned long *map, unsigned long *fill,NFT_PIPAPO_AVX2_BUCKET_LOAD8 (4 , lt,4 , pkt[4 ], bsize);NFT_PIPAPO_AVX2_AND (5 ,0 ,1 ); -NFT_PIPAPO_AVX2_BUCKET_LOAD8 (6 , lt,6 , pkt[5 ], bsize); +NFT_PIPAPO_AVX2_BUCKET_LOAD8 (6 , lt,5 , pkt[5 ], bsize);NFT_PIPAPO_AVX2_AND (7 ,2 ,3 );/* Stall */
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 4/7 selftests: netfilter: Add correctness test for mac,net set type
In reply to Pablo Neira AyusoFrom: Stefano Brivio <[email protected]>
The existing net,mac test didn't cover the issue recently reported by Nikita Yushchenko, where MAC addresses wouldn't match if given as first field of a concatenated set with AVX2 and 8-bit groups, because there's a different code path covering the lookup of six 8-bit groups (MAC addresses) if that's the first field.
Add a similar mac,net test, with MAC address and IPv4 address swapped in the set specification.
--- .../selftests/netfilter/nft_concat_range.sh | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
tools/testing/selftests/netfilter/nft_concat_range.sh +21 -3
@@ -23,8 +23,8 @@ TESTS="reported_issues correctness concurrency timeout" # Set types, defined by TYPE_ variables below TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto - net_port_net net_mac net_mac_icmp net6_mac_icmp net6_port_net6_port - net_port_mac_proto_net" + net_port_net net_mac mac_net net_mac_icmp net6_mac_icmp + net6_port_net6_port net_port_mac_proto_net" # Reported bugs, also described by TYPE_ variables below BUGS="flush_remove_add"
@@ -277,6 +277,23 @@ perf_entries 1000 perf_proto ipv4 " +TYPE_mac_net=" +display mac,net +type_spec ether_addr . ipv4_addr +chain_spec ether saddr . ip saddr +dst +src mac addr4 +start 1 +count 5 +src_delta 2000 +tools sendip nc bash +proto udp + +race_repeat 0 + +perf_duration 0 +" + TYPE_net_mac_icmp=" display net,mac - ICMP type_spec ipv4_addr . ether_addr
@@ -984,7 +1001,8 @@ format() { fi done for f in ${src}; do - __expr="${__expr} . " + [ "${__expr}" != "{ " ] && __expr="${__expr} . " + __start="$(eval format_"${f}" "${srcstart}")" __end="$(eval format_"${f}" "${srcend}")"
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 5/7 netfilter: nft_exthdr: break evaluation if setting TCP option fails
In reply to Pablo Neira AyusoBreak rule evaluation on malformed TCP options.
--- net/netfilter/nft_exthdr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/netfilter/nft_exthdr.c +7 -4
@@ -236,7 +236,7 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr, tcph =nft_tcp_header_pointer (pkt,sizeof (buff), buff, &tcphdr_len);if (!tcph) -return ; + goto err; opt = (u8 *)tcph;for (i =sizeof (*tcph); i < tcphdr_len -1 ; i += optl) {
@@ -251,16 +251,16 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,continue ;if (i + optl > tcphdr_len || priv->len + priv->offset > optl) -return ; + goto err;if (skb_ensure_writable (pkt->skb,nft_thoff (pkt) + i + priv->len)) -return ; + goto err; tcph =nft_tcp_header_pointer (pkt,sizeof (buff), buff, &tcphdr_len);if (!tcph) -return ; + goto err; offset = i + priv->offset;
@@ -303,6 +303,9 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,return ; } +return ; +err: + regs->verdict.code =NFT_BREAK ; } static void nft_exthdr_sctp_eval(const struct nft_expr *expr,
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 6/7 selftests: netfilter: switch zone stress to socat
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
centos9 has nmap-ncat which doesn't like the '-q' option, use socat. While at it, mark test skipped if needed tools are missing.
--- .../selftests/netfilter/nft_zones_many.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
tools/testing/selftests/netfilter/nft_zones_many.sh +13 -6
@@ -18,11 +18,17 @@ cleanup() ip netns del $ns } -ip netns add $ns -if [ $? -ne 0 ];then - echo "SKIP: Could not create net namespace $gw" - exit $ksft_skip -fi +checktool (){ + if ! $1 > /dev/null 2>&1; then + echo "SKIP: Could not $2" + exit $ksft_skip + fi +} + +checktool "nft --version" "run test without nft tool" +checktool "ip -Version" "run test without ip tool" +checktool "socat -V" "run test without socat tool" +checktool "ip netns add $ns" "create net namespace" trap cleanup EXIT
@@ -71,7 +77,8 @@ EOF local start=$(date +%s%3N) i=$((i + 10000)) j=$((j + 1)) - dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" nc -w 1 -q 1 -u -p 12345 127.0.0.1 12345 > /dev/null + # nft rule in output places each packet in a different zone. + dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" socat STDIN UDP:127.0.0.1:12345,sourceport=12345 if [ $? -ne 0 ] ;then ret=1 break
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 7/7 netfilter: conntrack: annotate data-races around ct->timeout
In reply to Pablo Neira AyusoFrom: Eric Dumazet <[email protected]>
(struct nf_conn)->timeout can be read/written locklessly, add READ_ONCE()/WRITE_ONCE() to prevent load/store tearing.
BUG: KCSAN: data-race in __nf_conntrack_alloc / __nf_conntrack_find_get
write to 0xffff888132e78c08 of 4 bytes by task 6029 on cpu 0:
__nf_conntrack_alloc+0x158/0x280 net/netfilter/nf_conntrack_core.c:1563 init_conntrack+0x1da/0xb30 net/netfilter/nf_conntrack_core.c:1635 resolve_normal_ct+0x502/0x610 net/netfilter/nf_conntrack_core.c:1746 nf_conntrack_in+0x1c5/0x88f net/netfilter/nf_conntrack_core.c:1901 ipv6_conntrack_local+0x19/0x20 net/netfilter/nf_conntrack_proto.c:414 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline] nf_hook_slow+0x72/0x170 net/netfilter/core.c:619 nf_hook include/linux/netfilter.h:262 [inline] NF_HOOK include/linux/netfilter.h:305 [inline] ip6_xmit+0xa3a/0xa60 net/ipv6/ip6_output.c:324 inet6_csk_xmit+0x1a2/0x1e0 net/ipv6/inet6_connection_sock.c:135 __tcp_transmit_skb+0x132a/0x1840 net/ipv4/tcp_output.c:1402 tcp_transmit_skb net/ipv4/tcp_output.c:1420 [inline] tcp_write_xmit+0x1450/0x4460 net/ipv4/tcp_output.c:2680 __tcp_push_pending_frames+0x68/0x1c0 net/ipv4/tcp_output.c:2864 tcp_push_pending_frames include/net/tcp.h:1897 [inline] tcp_data_snd_check+0x62/0x2e0 net/ipv4/tcp_input.c:5452 tcp_rcv_established+0x880/0x10e0 net/ipv4/tcp_input.c:5947 tcp_v6_do_rcv+0x36e/0xa50 net/ipv6/tcp_ipv6.c:1521 sk_backlog_rcv include/net/sock.h:1030 [inline] __release_sock+0xf2/0x270 net/core/sock.c:2768 release_sock+0x40/0x110 net/core/sock.c:3300 sk_stream_wait_memory+0x435/0x700 net/core/stream.c:145 tcp_sendmsg_locked+0xb85/0x25a0 net/ipv4/tcp.c:1402 tcp_sendmsg+0x2c/0x40 net/ipv4/tcp.c:1440 inet6_sendmsg+0x5f/0x80 net/ipv6/af_inet6.c:644 sock_sendmsg_nosec net/socket.c:704 [inline] sock_sendmsg net/socket.c:724 [inline] __sys_sendto+0x21e/0x2c0 net/socket.c:2036 __do_sys_sendto net/socket.c:2048 [inline] __se_sys_sendto net/socket.c:2044 [inline] __x64_sys_sendto+0x74/0x90 net/socket.c:2044 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
read to 0xffff888132e78c08 of 4 bytes by task 17446 on cpu 1:
nf_ct_is_expired include/net/netfilter/nf_conntrack.h:286 [inline] ____nf_conntrack_find net/netfilter/nf_conntrack_core.c:776 [inline] __nf_conntrack_find_get+0x1c7/0xac0 net/netfilter/nf_conntrack_core.c:807 resolve_normal_ct+0x273/0x610 net/netfilter/nf_conntrack_core.c:1734 nf_conntrack_in+0x1c5/0x88f net/netfilter/nf_conntrack_core.c:1901 ipv6_conntrack_local+0x19/0x20 net/netfilter/nf_conntrack_proto.c:414 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline] nf_hook_slow+0x72/0x170 net/netfilter/core.c:619 nf_hook include/linux/netfilter.h:262 [inline] NF_HOOK include/linux/netfilter.h:305 [inline] ip6_xmit+0xa3a/0xa60 net/ipv6/ip6_output.c:324 inet6_csk_xmit+0x1a2/0x1e0 net/ipv6/inet6_connection_sock.c:135 __tcp_transmit_skb+0x132a/0x1840 net/ipv4/tcp_output.c:1402 __tcp_send_ack+0x1fd/0x300 net/ipv4/tcp_output.c:3956 tcp_send_ack+0x23/0x30 net/ipv4/tcp_output.c:3962 __tcp_ack_snd_check+0x2d8/0x510 net/ipv4/tcp_input.c:5478 tcp_ack_snd_check net/ipv4/tcp_input.c:5523 [inline] tcp_rcv_established+0x8c2/0x10e0 net/ipv4/tcp_input.c:5948 tcp_v6_do_rcv+0x36e/0xa50 net/ipv6/tcp_ipv6.c:1521 sk_backlog_rcv include/net/sock.h:1030 [inline] __release_sock+0xf2/0x270 net/core/sock.c:2768 release_sock+0x40/0x110 net/core/sock.c:3300 tcp_sendpage+0x94/0xb0 net/ipv4/tcp.c:1114 inet_sendpage+0x7f/0xc0 net/ipv4/af_inet.c:833 rds_tcp_xmit+0x376/0x5f0 net/rds/tcp_send.c:118 rds_send_xmit+0xbed/0x1500 net/rds/send.c:367 rds_send_worker+0x43/0x200 net/rds/threads.c:200 process_one_work+0x3fc/0x980 kernel/workqueue.c:2298 worker_thread+0x616/0xa70 kernel/workqueue.c:2445 kthread+0x2c7/0x2e0 kernel/kthread.c:327 ret_from_fork+0x1f/0x30
value changed: 0x00027cc2 -> 0x00000000
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 17446 Comm: kworker/u4:5 Tainted: G W 5.16.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: krdsd rds_send_worker
Note: I chose an arbitrary commit for the Fixes: tag, because I do not think we need to backport this fix to very old kernels.
--- include/net/netfilter/nf_conntrack.h | 6 +++--- net/netfilter/nf_conntrack_core.c | 6 +++--- net/netfilter/nf_conntrack_netlink.c | 2 +- net/netfilter/nf_flow_table_core.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-)
include/net/netfilter/nf_conntrack.h +3 -3
@@ -276,14 +276,14 @@ static inline bool nf_is_loopback_packet(const struct sk_buff *skb)/* jiffies until ct expires, 0 if already expired */ static inline unsigned long nf_ct_expires (const struct nf_conn *ct) { -s32 timeout = ct->timeout - nfct_time_stamp; +s32 timeout =READ_ONCE (ct->timeout) - nfct_time_stamp;return timeout >0 ? timeout :0 ; }static inline bool nf_ct_is_expired (const struct nf_conn *ct) { -return (__s32)(ct->timeout - nfct_time_stamp) <=0 ; +return (__s32)(READ_ONCE (ct->timeout) - nfct_time_stamp) <=0 ; }/* use after obtaining a reference count */
@@ -302,7 +302,7 @@ static inline bool nf_ct_should_gc(const struct nf_conn *ct)static inline void nf_ct_offload_timeout (struct nf_conn *ct) {if (nf_ct_expires (ct) <NF_CT_DAY /2 ) - ct->timeout = nfct_time_stamp +NF_CT_DAY ; +WRITE_ONCE (ct->timeout, nfct_time_stamp +NF_CT_DAY ); }struct kernel_param ;
net/netfilter/nf_conntrack_core.c +3 -3
@@ -684,7 +684,7 @@ bool nf_ct_delete(struct nf_conn *ct, u32 portid, int report) tstamp =nf_conn_tstamp_find (ct);if (tstamp) { -s32 timeout = ct->timeout - nfct_time_stamp; +s32 timeout =READ_ONCE (ct->timeout) - nfct_time_stamp; tstamp->stop =ktime_get_real_ns ();if (timeout <0 )
@@ -1036,7 +1036,7 @@ static int nf_ct_resolve_clash_harder(struct sk_buff *skb, u32 repl_idx) }/* We want the clashing entry to go away real soon: 1 second timeout. */ - loser_ct->timeout = nfct_time_stamp +HZ ; +WRITE_ONCE (loser_ct->timeout, nfct_time_stamp +HZ );/* IPS_NAT_CLASH removes the entry automatically on the first * reply. Also prevents UDP tracker from moving the entry to
@@ -1560,7 +1560,7 @@ __nf_conntrack_alloc(struct net *net,/* save hash for reusing when confirming */ *(unsigned long *)(&ct->tuplehash[IP_CT_DIR_REPLY ].hnnode.pprev) = hash; ct->status =0 ; - ct->timeout =0 ; +WRITE_ONCE (ct->timeout,0 );write_pnet (&ct->ct_net, net); memset(&ct->__nfct_init_offset, 0, offsetof(struct nf_conn, proto) -
net/netfilter/nf_conntrack_netlink.c +1 -1
@@ -1998,7 +1998,7 @@ static int ctnetlink_change_timeout(struct nf_conn *ct,if (timeout >INT_MAX ) timeout =INT_MAX ; - ct->timeout = nfct_time_stamp + (u32 )timeout; +WRITE_ONCE (ct->timeout, nfct_time_stamp + (u32 )timeout);if (test_bit (IPS_DYING_BIT , &ct->status))return -ETIME ;
net/netfilter/nf_flow_table_core.c +2 -2
@@ -201,8 +201,8 @@ static void flow_offload_fixup_ct_timeout(struct nf_conn *ct)if (timeout <0 ) timeout =0 ; -if (nf_flow_timeout_delta (ct->timeout) > (__s32 )timeout) - ct->timeout = nfct_time_stamp + timeout; +if (nf_flow_timeout_delta (READ_ONCE (ct->timeout)) > (__s32 )timeout) +WRITE_ONCE (ct->timeout, nfct_time_stamp + timeout); }static void flow_offload_fixup_ct_state (struct nf_conn *ct)
Signature · 1 line
2.30.2