lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 16 Jan 2024 11:38:47 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Zhengchao Shao <shaozhengchao@...wei.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org, 
	pabeni@...hat.com, dsahern@...nel.org, hkchu@...gle.com, 
	weiyongjun1@...wei.com, yuehaibing@...wei.com
Subject: Re: [PATCH net,v2] tcp: make sure init the accept_queue's spinlocks once

On Sat, Jan 13, 2024 at 3:57 AM Zhengchao Shao <shaozhengchao@...wei.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@...wei.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'...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ