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: <2023062838-precut-hacker-40bd@gregkh>
Date:   Wed, 28 Jun 2023 13:47:54 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Chengfeng Ye <dg573847474@...il.com>
Cc:     scott.branden@...adcom.com, bcm-kernel-feedback-list@...adcom.com,
        arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] misc: bcm_vk: Fix potential deadlock on &vk->ctx_lock

On Wed, Jun 28, 2023 at 11:29:58AM +0000, Chengfeng Ye wrote:
> As &vk->ctx_lock is acquired by timer bcm_vk_hb_poll() under softirq
> context, other process context code should disable irq or bottom-half
> before acquire the same lock, otherwise deadlock could happen if the
> timer preempt the execution while the lock is held in process context
> on the same CPU.
> 
> Possible deadlock scenario
> bcm_vk_open()
>     -> bcm_vk_get_ctx()
>     -> spin_lock(&vk->ctx_lock)
> 	<timer iterrupt>
> 	-> bcm_vk_hb_poll()
> 	-> bcm_vk_blk_drv_access()
> 	-> spin_lock_irqsave(&vk->ctx_lock, flags) (deadlock here)
> 
> This flaw was found using an experimental static analysis tool we are
> developing for irq-related deadlock, which reported the following
> warning when analyzing the linux kernel 6.4-rc7 release.
> 
> [Deadlock]: &vk->ctx_lock
>   [Interrupt]: bcm_vk_hb_poll
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:176
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:512
>   [Locking Unit]: bcm_vk_ioctl
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:1181
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:512
> 
> [Deadlock]: &vk->ctx_lock
>   [Interrupt]: bcm_vk_hb_poll
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:176
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:512
>   [Locking Unit]: bcm_vk_ioctl
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:1169
> 
> [Deadlock]: &vk->ctx_lock
>   [Interrupt]: bcm_vk_hb_poll
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:176
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:512
>   [Locking Unit]: bcm_vk_open
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:216
> 
> [Deadlock]: &vk->ctx_lock
>   [Interrupt]: bcm_vk_hb_poll
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:176
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_dev.c:512
>   [Locking Unit]: bcm_vk_release
>     -->/root/linux/drivers/misc/bcm-vk/bcm_vk_msg.c:306
> 
> The tentative patch fix the potential deadlock by spin_lock_irqsave().
> 
> Signed-off-by: Chengfeng Ye <dg573847474@...il.com>
> ---

You do not mention how you tested to verify that your change is correct
:(

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ