[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <53c7fc83-7599-451f-91ff-309e55defd48@redhat.com>
Date: Tue, 1 Oct 2024 12:53:04 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Simon Horman <horms@...nel.org>, David Howells <dhowells@...hat.com>
Cc: netdev@...r.kernel.org, yuxuanzhe@...look.com,
Marc Dionne <marc.dionne@...istor.com>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, linux-afs@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] rxrpc: Fix a race between socket set up and I/O
thread creation
On 9/25/24 20:33, Simon Horman wrote:
> On Tue, Sep 24, 2024 at 11:08:01PM +0100, David Howells wrote:
>> In rxrpc_open_socket(), it sets up the socket and then sets up the I/O
>> thread that will handle it. This is a problem, however, as there's a gap
>> between the two phases in which a packet may come into rxrpc_encap_rcv()
>> from the UDP packet but we oops when trying to wake the not-yet created I/O
>> thread.
>>
>> As a quick fix, just make rxrpc_encap_rcv() discard the packet if there's
>> no I/O thread yet.
>>
>> A better, but more intrusive fix would perhaps be to rearrange things such
>> that the socket creation is done by the I/O thread.
>>
>> Fixes: a275da62e8c1 ("rxrpc: Create a per-local endpoint receive queue and I/O thread")
>> Signed-off-by: David Howells <dhowells@...hat.com>
>> Reviewed-by: Eric Dumazet <edumazet@...gle.com>
>
> ...:wq
>
>> diff --git a/net/rxrpc/io_thread.c b/net/rxrpc/io_thread.c
>> index 0300baa9afcd..5c0a5374d51a 100644
>> --- a/net/rxrpc/io_thread.c
>> +++ b/net/rxrpc/io_thread.c
>> @@ -27,8 +27,9 @@ int rxrpc_encap_rcv(struct sock *udp_sk, struct sk_buff *skb)
>> {
>> struct sk_buff_head *rx_queue;
>> struct rxrpc_local *local = rcu_dereference_sk_user_data(udp_sk);
>> + struct task_struct *io_thread = READ_ONCE(local->io_thread);
>
> Hi David,
>
> The line above dereferences local.
> But the line below assumes that it may be NULL.
> This seems inconsistent.
sk->sk_user_data is cleared just before io_thread by rxrpc_io_thread(),
I think accessing a NULL 'local' here should be possible.
@David, could you please respin addressing the above?
Thanks!
Paolo
Powered by blists - more mailing lists