From: shaozhengchao <shaozhengchao@huawei.com>
To: Eric Dumazet <edumazet@google.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
<kuba@kernel.org>, <pabeni@redhat.com>, <dsahern@kernel.org>,
<hkchu@google.com>, <weiyongjun1@huawei.com>,
<yuehaibing@huawei.com>
Subject: Re: [PATCH net,v2] tcp: make sure init the accept_queue's spinlocks once
Date: Wed, 17 Jan 2024 10:48:53 +0800 [thread overview]
Message-ID: <a0adea69-aea1-d35a-6a34-e1544a7ce1a5@huawei.com> (raw)
In-Reply-To: <CANn89i+nmdm5aRNC0mvuVufyRq+fzvKMU9KtSdBMXjMBosgxTA@mail.gmail.com>
On 2024/1/16 18:38, Eric Dumazet wrote:
> On Sat, Jan 13, 2024 at 3:57 AM Zhengchao Shao <shaozhengchao@huawei.com> wrote:
>>
>> When I run syz's reproduction C program locally, it causes the following
>> issue:
>> pvqspinlock: lock 0xffff9d181cd5c660 has corrupted value 0x0!
>> WARNING: CPU: 19 PID: 21160 at __pv_queued_spin_unlock_slowpath (kernel/locking/qspinlock_paravirt.h:508)
>> Ha
>
>
>> When the socket receives the ACK packet during the three-way handshake,
>> it will hold spinlock. And then the user actively shutdowns the socket
>> and listens to the socket immediately, the spinlock will be initialized.
>> When the socket is going to release the spinlock, a warning is generated.
>> Also the same issue to fastopenq.lock.
>>
>> Add 'init_done' to make sure init the accept_queue's spinlocks once.
>>
>> Fixes: fff1f3001cc5 ("tcp: add a spinlock to protect struct request_sock_queue")
>> Fixes: 168a8f58059a ("tcp: TCP Fast Open Server - main code path")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>> v2: Add 'init_done' to make sure init the accept_queue's spinlocks once.
>> ---
>> include/net/request_sock.h | 1 +
>> net/core/request_sock.c | 7 +++++--
>> net/ipv4/tcp.c | 1 +
>> 3 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/net/request_sock.h b/include/net/request_sock.h
>> index 144c39db9898..0054746fe92d 100644
>> --- a/include/net/request_sock.h
>> +++ b/include/net/request_sock.h
>> @@ -175,6 +175,7 @@ struct fastopen_queue {
>> struct request_sock_queue {
>> spinlock_t rskq_lock;
>> u8 rskq_defer_accept;
>> + bool init_done;
>>
>
> No, we should not add a new field for this.
> The idea of having a conditional spin_lock_init() is not very nice
> for code readability.
>
> Just always init request_sock_queue spinlocks for all inet sockets at
> socket() and accept() time,
> not at listen() time.
>
> This structure is not dynamically allocated, and part of 'struct
> inet_connection_sock'...
Hi Eric:
It looks good to me. I will send V3.
Thank you.
Zhengchao Shao
prev parent reply other threads:[~2024-01-17 2:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-13 3:07 [PATCH net,v2] tcp: make sure init the accept_queue's spinlocks once Zhengchao Shao
2024-01-16 10:26 ` Paolo Abeni
2024-01-17 2:52 ` shaozhengchao
2024-01-16 10:38 ` Eric Dumazet
2024-01-17 2:48 ` shaozhengchao [this message]
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=a0adea69-aea1-d35a-6a34-e1544a7ce1a5@huawei.com \
--to=shaozhengchao@huawei.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hkchu@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=weiyongjun1@huawei.com \
--cc=yuehaibing@huawei.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