From: Eric Dumazet <edumazet@google.com>
To: Zhengchao Shao <shaozhengchao@huawei.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: Tue, 16 Jan 2024 11:38:47 +0100 [thread overview]
Message-ID: <CANn89i+nmdm5aRNC0mvuVufyRq+fzvKMU9KtSdBMXjMBosgxTA@mail.gmail.com> (raw)
In-Reply-To: <20240113030739.3446338-1-shaozhengchao@huawei.com>
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'...
next prev parent reply other threads:[~2024-01-16 10:39 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 [this message]
2024-01-17 2:48 ` shaozhengchao
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=CANn89i+nmdm5aRNC0mvuVufyRq+fzvKMU9KtSdBMXjMBosgxTA@mail.gmail.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=hkchu@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaozhengchao@huawei.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;
as well as URLs for NNTP newsgroup(s).