Re: [PATCH v3] watchdog: s3c2410: Fix potential deadlock on &wdt->lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/5/23 02:09, Chengfeng Ye wrote:
As &wdt->lock is acquired by hard irq s3c2410wdt_irq(),
other acquisition of the same lock under process context 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.

[Deadlock Scenario]
s3c2410wdt_suspend()
     -> s3c2410wdt_stop()
     -> spin_lock(&wdt->lock)
         <irq iterrupt>
         -> s3c2410wdt_irq()
         -> s3c2410wdt_keepalive()
         -> spin_lock(&wdt->lock) (deadlock here)

[Deadlock Scenario]
s3c2410wdt_probe()
     -> s3c2410wdt_start()
     -> spin_lock(&wdt->lock)
         <irq iterrupt>
         -> s3c2410wdt_irq()
         -> s3c2410wdt_keepalive()
         -> spin_lock(&wdt->lock) (deadlock here)

[Deadlock Scenario]
s3c2410wdt_keepalive()
     -> spin_lock(&wdt->lock)
         <irq iterrupt>
         -> s3c2410wdt_irq()
         -> s3c2410wdt_keepalive()
         -> spin_lock(&wdt->lock) (deadlock here)

This flaw was found by an experimental static analysis tool I am
developing for irq-related deadlock, which reported the above
warning when analyzing the linux kernel 6.4-rc7 release.

The tentative patch fix the potential deadlock by spin_lock_irqsave()
under process context.

Signed-off-by: Chengfeng Ye <dg573847474@xxxxxxxxx>

I am sure you know what you changed in each version of your patches. I don't.
Please provide change logs when you send new versions of your patches.

Guenter




[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux for Synopsys ARC Processors]    
  • [Linux on Unisoc (RDA Micro) SoCs]     [Linux Actions SoC]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  •   Powered by Linux