netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Zhang Tengfei <zhtfdev@gmail.com>
Cc: ja@ssi.bg, coreteam@netfilter.org, davem@davemloft.net,
	dsahern@kernel.org, edumazet@google.com, fw@strlen.de,
	horms@verge.net.au, kadlec@netfilter.org, kuba@kernel.org,
	lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	pabeni@redhat.com,
	syzbot+1651b5234028c294c339@syzkaller.appspotmail.com
Subject: Re:
Date: Wed, 27 Aug 2025 23:37:05 +0200	[thread overview]
Message-ID: <aK96gZBMvbJ73e_e@calendula> (raw)
In-Reply-To: <20250827144337.34792-1-zhtfdev@gmail.com>

On Wed, Aug 27, 2025 at 10:43:42PM +0800, Zhang Tengfei wrote:
> Hi everyone,
> 
> Here is the v2 patch that incorporates the feedback.

Patch without subject will not fly too far, I'm afraid you will have
to resubmit. One more comment below.

> Many thanks to Julian for his thorough review and for providing 
> the detailed plan for this new version, and thanks to Florian 
> and Eric for suggestions.
> 
> Subject: [PATCH v2] net/netfilter/ipvs: Use READ_ONCE/WRITE_ONCE for
>  ipvs->enable
> 
> KCSAN reported a data-race on the `ipvs->enable` flag, which is
> written in the control path and read concurrently from many other
> contexts.
> 
> Following a suggestion by Julian, this patch fixes the race by
> converting all accesses to use `WRITE_ONCE()/READ_ONCE()`.
> This lightweight approach ensures atomic access and acts as a
> compiler barrier, preventing unsafe optimizations where the flag
> is checked in loops (e.g., in ip_vs_est.c).
> 
> Additionally, the now-obsolete `enable` checks in the fast path
> hooks (`ip_vs_in_hook`, `ip_vs_out_hook`, `ip_vs_forward_icmp`)
> are removed. These are unnecessary since commit 857ca89711de
> ("ipvs: register hooks only with services").
> 
> Reported-by: syzbot+1651b5234028c294c339@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1651b5234028c294c339
> Suggested-by: Julian Anastasov <ja@ssi.bg>
> Link: https://lore.kernel.org/lvs-devel/2189fc62-e51e-78c9-d1de-d35b8e3657e3@ssi.bg/
> Signed-off-by: Zhang Tengfei <zhtfdev@gmail.com>
> 
> ---
> v2:
> - Switched from atomic_t to the suggested READ_ONCE()/WRITE_ONCE().
> - Removed obsolete checks from the packet processing hooks.
> - Polished commit message based on feedback.
> ---
>  net/netfilter/ipvs/ip_vs_conn.c |  4 ++--
>  net/netfilter/ipvs/ip_vs_core.c | 11 ++++-------
>  net/netfilter/ipvs/ip_vs_ctl.c  |  6 +++---
>  net/netfilter/ipvs/ip_vs_est.c  | 16 ++++++++--------
>  4 files changed, 17 insertions(+), 20 deletions(-)
[...]
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index c7a8a08b7..5ea7ab8bf 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1353,9 +1353,6 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stat
>  	if (unlikely(!skb_dst(skb)))
>  		return NF_ACCEPT;
>  
> -	if (!ipvs->enable)
> -		return NF_ACCEPT;

Patch does say why is this going away? If you think this is not
necessary, then make a separated patch and example why this is needed?

Thanks

>  	ip_vs_fill_iph_skb(af, skb, false, &iph);
>  #ifdef CONFIG_IP_VS_IPV6
>  	if (af == AF_INET6) {

  reply	other threads:[~2025-08-27 21:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26 13:31 [PATCH] net/netfilter/ipvs: Fix data-race in ip_vs_add_service / ip_vs_out_hook Zhang Tengfei
2025-08-26 14:18 ` Florian Westphal
2025-08-26 14:40   ` Eric Dumazet
2025-08-26 15:56 ` Julian Anastasov
2025-08-27  6:48 ` Julian Anastasov
2025-08-27 14:43   ` Zhang Tengfei
2025-08-27 21:37     ` Pablo Neira Ayuso [this message]
2025-08-27 22:33   ` [PATCH v2] net/netfilter/ipvs: Use READ_ONCE/WRITE_ONCE for ipvs->enable Zhang Tengfei
2025-08-27 22:51     ` Zhang Tengfei
2025-08-31 13:01     ` Julian Anastasov
2025-09-01 13:46       ` [PATCH v3 nf-next] ipvs: " Zhang Tengfei
2025-09-03 17:31         ` Julian Anastasov
  -- strict thread matches above, loose matches on Subject: below --
2017-11-13 14:56 Amos Kalonzo
2017-02-23 15:10 Qin's Yanjun
2015-10-24  5:02 RE: JO Bower
2015-08-19 14:04 christain147
2014-07-03 16:30 W. Cheung
2011-12-11  8:41 James Brown
     [not found] <20101010012607.zl4aj162o0004ok0@webmail.eon.net.au>
2010-10-09 21:56 ` Re: Mistick Levi
2010-04-10  0:33 Re: William Wilcox
2009-10-29 18:11 (unknown), Jan Engelhardt
2009-10-29 22:26 ` Patrick McHardy
2009-10-29 22:51   ` Re: Jan Engelhardt
2009-10-29 22:55     ` Re: Patrick McHardy
2009-08-05 16:22 (unknown), Jan Engelhardt
2009-08-10  9:04 ` Patrick McHardy
2009-07-25 20:22 (unknown), Jan Engelhardt
2009-08-03 13:45 ` Patrick McHardy
2009-06-26 19:19 (unknown), Jan Engelhardt
2009-06-29 12:56 ` Patrick McHardy
     [not found] <20050912163005.023FF14F583@ladon.telenet-ops.be>
2005-09-12 20:02 ` Re: David Stes
2003-04-03  3:26 Ian Latter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aK96gZBMvbJ73e_e@calendula \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+1651b5234028c294c339@syzkaller.appspotmail.com \
    --cc=zhtfdev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).