linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] fpga: dfl: possible ABBA deadlock in dfl_fpga_cdev_assign_port() and fme_pr()
@ 2021-11-23  7:55 Jia-Ju Bai
  2021-11-24 15:59 ` Wu, Hao
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-11-23  7:55 UTC (permalink / raw)
  To: hao.wu, trix, mdf; +Cc: linux-fpga, linux-kernel

Hello,

My static analysis tool reports a possible ABBA deadlock in the dfl 
driver in Linux 5.10:

dfl_fpga_cdev_assign_port()
   mutex_lock(&cdev->lock); --> Line 1067 (Lock A)
   mutex_lock(&pdata->lock); --> Line 1624 (Lock B)

fme_pr()
   mutex_lock(&pdata->lock); --> Line 126 (Lock B)
   fpga_region_program_fpga()
     fpga_bridges_enable()
       fpga_bridge_enable()
         fme_bridge_enable_set() --> function pointer via 
"bridge->br_ops->enable_set()"
           dfl_fpga_cdev_find_port()
             mutex_lock(&cdev->lock); --> Line 499 (LockA)

When dfl_fpga_cdev_assign_port() and fme_pr() are concurrently executed, 
the deadlock can occur.

I am not quite sure whether this possible deadlock is real and how to 
fix it if it is real.
Any feedback would be appreciated, thanks

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>


Best wishes,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [BUG] fpga: dfl: possible ABBA deadlock in dfl_fpga_cdev_assign_port() and fme_pr()
  2021-11-23  7:55 [BUG] fpga: dfl: possible ABBA deadlock in dfl_fpga_cdev_assign_port() and fme_pr() Jia-Ju Bai
@ 2021-11-24 15:59 ` Wu, Hao
  0 siblings, 0 replies; 2+ messages in thread
From: Wu, Hao @ 2021-11-24 15:59 UTC (permalink / raw)
  To: Jia-Ju Bai, trix, mdf; +Cc: linux-fpga, linux-kernel

> 
> dfl_fpga_cdev_assign_port()
>    mutex_lock(&cdev->lock); --> Line 1067 (Lock A)
>    mutex_lock(&pdata->lock); --> Line 1624 (Lock B)

This lock is from port platform device.

> 
> fme_pr()
>    mutex_lock(&pdata->lock); --> Line 126 (Lock B)

This lock is from fme platform device.

Actually they are different locks, but yes, maybe we should consider
improving the naming to avoid misunderstanding.

Thanks
Hao

>    fpga_region_program_fpga()
>      fpga_bridges_enable()
>        fpga_bridge_enable()
>          fme_bridge_enable_set() --> function pointer via
> "bridge->br_ops->enable_set()"
>            dfl_fpga_cdev_find_port()
>              mutex_lock(&cdev->lock); --> Line 499 (LockA)
> 
> When dfl_fpga_cdev_assign_port() and fme_pr() are concurrently executed,
> the deadlock can occur.
> 
> I am not quite sure whether this possible deadlock is real and how to
> fix it if it is real.
> Any feedback would be appreciated, thanks
> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> 
> 
> Best wishes,
> Jia-Ju Bai

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-24 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23  7:55 [BUG] fpga: dfl: possible ABBA deadlock in dfl_fpga_cdev_assign_port() and fme_pr() Jia-Ju Bai
2021-11-24 15:59 ` Wu, Hao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).