Re: [PATCH V2] ax25: Fix potential deadlock on &ax25_list_lock

From: Simon Horman
Date: Sat Oct 07 2023 - 11:13:30 EST


On Thu, Oct 05, 2023 at 07:23:49AM +0000, Chengfeng Ye wrote:
> Timer interrupt ax25_ds_timeout() could introduce double locks on
> &ax25_list_lock.
>
> ax25_ioctl()
> --> ax25_ctl_ioctl()
> --> ax25_dama_off()
> --> ax25_dev_dama_off()
> --> ax25_check_dama_slave()
> --> spin_lock(&ax25_list_lock)
> <timer interrupt>
> --> ax25_ds_timeout()
> --> spin_lock(&ax25_list_lock)
>
> This flaw was found by an experimental static analysis tool I am
> developing for irq-related deadlock.
>
> To prevent the potential deadlock, the patch use spin_lock_bh()
> on &ax25_list_lock inside ax25_check_dama_slave().
>
> Fixes: c19c4b9c9acb ("[AX.25]: Optimize AX.25 socket list lock")
> Signed-off-by: Chengfeng Ye <dg573847474@xxxxxxxxx>

Hi Chengfeng Ye,

Are there other functions that spin_lock(&ax25_list_lock)
that also need to use spin_lock_bh()?

...