Re: [PATCH] misc: bcm_vk: Fix potential deadlock on &vk->ctx_lock

From: Chengfeng Ye
Date: Wed Jun 28 2023 - 07:32:50 EST


Thanks for the reply! V2 patch is sent including more detail of the static
analyzer and testing process.

Best Regards,
Chengfeng

Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> 于2023年6月28日周三 19:00写道:
>
> On Wed, Jun 28, 2023 at 10:52:50AM +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.
> >
> > The tentative patch fix the potential deadlock by spin_lock_irqsave().
>
> how was this tested? As per the file,
> Documentation/process/researcher-guidelines.rst, you have to show this.
>
> thanks,
>
> greg k-h