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: <25b4000b-b61d-c109-0d5c-f71656d896d4@suse.de>
Date:   Wed, 16 Aug 2023 19:10:03 +0200
From:   Hannes Reinecke <hare@...e.de>
To:     Chengfeng Ye <dg573847474@...il.com>, jejb@...ux.ibm.com,
        martin.petersen@...cle.com, bigeasy@...utronix.de,
        dave@...olabs.net, satishkh@...co.com, sebaddel@...co.com,
        kartilak@...co.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] scsi: fcoe: Fix potential deadlock on
 &fip->ctlr_lock

On 8/16/23 17:55, Chengfeng Ye wrote:
> There is a long call chain that &fip->ctlr_lock is acquired by isr
> fnic_isr_msix_wq_copy() under hard irq context. Thus other process
> context code acquiring the lock should disable irq, otherwise
> deadlock could happen if the irq preempt the execution while the
> lock is held in process context on the same CPU.
> 
> [ISR]
> fnic_isr_msix_wq_copy()
>   -> fnic_wq_copy_cmpl_handler()
>   -> fnic_fcpio_cmpl_handler()
>   -> fnic_fcpio_flogi_reg_cmpl_handler()
>   -> fnic_flush_tx()
>   -> fnic_send_frame()
>   -> fcoe_ctlr_els_send()
>   -> spin_lock_bh(&fip->ctlr_lock)
> 
> [Process Context]
> 1. fcoe_ctlr_timer_work()
>   -> fcoe_ctlr_flogi_send()
>   -> spin_lock_bh(&fip->ctlr_lock)
> 
> 2. fcoe_ctlr_recv_work()
>   -> fcoe_ctlr_recv_handler()
>   -> fcoe_ctlr_recv_els()
>   -> fcoe_ctlr_announce()
>   -> spin_lock_bh(&fip->ctlr_lock)
> 
> 3. fcoe_ctlr_recv_work()
>   -> fcoe_ctlr_recv_handler()
>   -> fcoe_ctlr_recv_els()
>   -> fcoe_ctlr_flogi_retry()
>   -> spin_lock_bh(&fip->ctlr_lock)
> 
> 4. -> fcoe_xmit()
>   -> fcoe_ctlr_els_send()
>   -> spin_lock_bh(&fip->ctlr_lock)
> 
> spin_lock_bh() is not enough since fnic_isr_msix_wq_copy() is a
> hardirq.
> 
> These flaws were found by an experimental static analysis tool I am
> developing for irq-related deadlock.
> 
> The patch fix the potential deadlocks by spin_lock_irqsave() to
> disable hard irq.
> 
> Signed-off-by: Chengfeng Ye <dg573847474@...il.com>
> ---
>   drivers/scsi/fcoe/fcoe_ctlr.c | 20 ++++++++++++--------
>   1 file changed, 12 insertions(+), 8 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@...e.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@...e.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ