Re: [PATCH] netfilter: mark racy access on ext->gen_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 25, 2024 at 11:36 AM Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> wrote:
>
> On Tue, Apr 23, 2024 at 07:50:22PM +0800, linke li wrote:
> > 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.
>
> There are a more uses ext->gen_id in the code, my understanding this
> patch is just a stub.

Anyway, ext->gen_id was already read and stored in @this_id

I would probably avoid reading it a second time.

diff --git a/net/netfilter/nf_conntrack_extend.c
b/net/netfilter/nf_conntrack_extend.c
index dd62cc12e7750734fec9be8a90fd0defcbc815e0..747797b20bc7417a2b7270d84f62d24991a4b982
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 || this_id == gen_id)
                return (void *)ext + ext->offset[id];

        return NULL;





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux