[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZW2w3YyNMoyN1t97@debian>
Date: Mon, 4 Dec 2023 11:58:37 +0100
From: Guillaume Nault <gnault@...hat.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Kuniyuki Iwashima <kuniyu@...zon.com>, davem@...emloft.net,
dsahern@...nel.org, kuba@...nel.org, mkubecek@...e.cz,
netdev@...r.kernel.org, pabeni@...hat.com
Subject: Re: [PATCH net-next v4] tcp: Dump bound-only sockets in inet_diag.
On Fri, Dec 01, 2023 at 09:41:16PM +0100, Eric Dumazet wrote:
> On Fri, Dec 1, 2023 at 9:34 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > From: Guillaume Nault <gnault@...hat.com>
>
> > > + goto next_bind;
> > > +
> > > + if (sk->sk_state != TCP_CLOSE ||
> > > + !inet->inet_num)
> >
> > Sorry for missing this in the previous version, but I think
> > inet_num is always non-zero because 0 selects a port automatically
> > and the min of ipv4_local_port_range is 1.
> >
>
> This is not true, because it can be cleared by another thread, before
> unhashing happens in __inet_put_port()
>
> Note the test should use READ_ONCE(inet->inet_num), but I did not
> mention this, as many reads of inet_num are racy.
Would you like me to send a v5, or do you prefer to let a future series
fix all the racy reads and writes at once?
Personally, I feel it'd look strange to have a READ_ONCE() only in
inet_diag_dump_icsk(), while the rest of the stack accesses it
directly. But just let me know if you feel otherwise and I'll post a
v5.
Powered by blists - more mailing lists