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]
Message-ID: <CADvbK_faoh-=8AZ7s+ak9QpmGQa_GddikWvyYW_b0Lb8=mNcJA@mail.gmail.com>
Date: Tue, 27 Jun 2023 13:33:18 -0400
From: Xin Long <lucien.xin@...il.com>
To: Chengfeng Ye <dg573847474@...il.com>
Cc: marcelo.leitner@...il.com, davem@...emloft.net, edumazet@...gle.com, 
	kuba@...nel.org, pabeni@...hat.com, linux-sctp@...r.kernel.org, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sctp: fix potential deadlock on &net->sctp.addr_wq_lock

On Tue, Jun 27, 2023 at 8:04 AM Chengfeng Ye <dg573847474@...il.com> wrote:
>
> As &net->sctp.addr_wq_lock is also acquired by the timer
> sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition
> at sctp_auto_asconf_init() seems should disable irq since it is called
> from sctp_accept() under process context.
>
> Possible deadlock scenario:
> sctp_accept()
>     -> sctp_sock_migrate()
>     -> sctp_auto_asconf_init()
>     -> spin_lock(&net->sctp.addr_wq_lock)
>         <timer interrupt>
>         -> sctp_addr_wq_timeout_handler()
>         -> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)
>
> This flaw was found using an experimental static analysis tool we are
> developing for irq-related deadlock.
>
> The tentative patch fix the potential deadlock by spin_lock_bh().
>
> Signed-off-by: Chengfeng Ye <dg573847474@...il.com>
> ---
>  net/sctp/socket.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index cda8c2874691..b2c7d17ff848 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -364,9 +364,9 @@ static void sctp_auto_asconf_init(struct sctp_sock *sp)
>         struct net *net = sock_net(&sp->inet.sk);
>
>         if (net->sctp.default_auto_asconf) {
> -               spin_lock(&net->sctp.addr_wq_lock);
> +               spin_lock_bh(&net->sctp.addr_wq_lock);
>                 list_add_tail(&sp->auto_asconf_list, &net->sctp.auto_asconf_splist);
> -               spin_unlock(&net->sctp.addr_wq_lock);
> +               spin_unlock_bh(&net->sctp.addr_wq_lock);
>                 sp->do_auto_asconf = 1;
>         }
>  }
> --
> 2.17.1
>
Fixes: 34e5b0118685 ("sctp: delay auto_asconf init until binding the
first addr")
Acked-by: Xin Long <lucien.xin@...il.com>

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ