From: linke li <lilinke99@qq.com>
Cc: xujianhao01@gmail.com, linke li <lilinke99@qq.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] netfilter: mark racy access on ext->gen_id
Date: Tue, 23 Apr 2024 19:50:22 +0800 [thread overview]
Message-ID: <tencent_284407955020261D1B2BD142194A87C9EB0A@qq.com> (raw)
In __nf_ct_ext_find(), ext->gen_id can be changed by
nf_ct_ext_valid_post(), using WRITE_ONCE. Mark data races on ext->gen_id
as benign using READ_ONCE.
This patch is aimed at reducing the number of benign races reported by
KCSAN in order to focus future debugging effort on harmful races.
Signed-off-by: linke li <lilinke99@qq.com>
---
net/netfilter/nf_conntrack_extend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index dd62cc12e775..7f1a5e5f6646 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -141,7 +141,7 @@ void *__nf_ct_ext_find(const struct nf_ct_ext *ext, u8 id)
if (!__nf_ct_ext_exist(ext, id))
return NULL;
- if (this_id == 0 || ext->gen_id == gen_id)
+ if (this_id == 0 || READ_ONCE(ext->gen_id) == gen_id)
return (void *)ext + ext->offset[id];
return NULL;
--
2.39.3 (Apple Git-146)
next reply other threads:[~2024-04-23 11:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 11:50 linke li [this message]
2024-04-23 12:03 ` [PATCH] netfilter: mark racy access on ext->gen_id Florian Westphal
2024-04-24 22:20 ` Pablo Neira Ayuso
2024-04-25 9:36 ` Pablo Neira Ayuso
2024-04-25 9:54 ` Eric Dumazet
2024-04-25 10:04 ` Florian Westphal
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=tencent_284407955020261D1B2BD142194A87C9EB0A@qq.com \
--to=lilinke99@qq.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=xujianhao01@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 read-only IMAP folder(s) and NNTP newsgroup(s).