mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents()
@ 2021-12-10  8:38 Jia-Ju Bai
  2021-12-14  7:08 ` Joseph Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Jia-Ju Bai @ 2021-12-10  8:38 UTC (permalink / raw)
  To: mark, jlbec, joseph.qi; +Cc: ocfs2-devel, linux-kernel

Hello,

My static analysis tool reports a possible ABBA deadlock in the ocfs2 
module in Linux 5.10:

ocfs2_dio_end_io_write()
   down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A)
   ocfs2_del_inode_from_orphan()
     inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

ocfs2_move_extents()
   inode_lock(inode); --> Line 916 (Lock B)
   down_write(&OCFS2_I(inode)->ip_alloc_sem); --> Line 936 (Lock A)

When ocfs2_dio_end_io_write() and ocfs2_move_extents() are concurrently 
executed, the deadlocks 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] 4+ messages in thread

* Re: [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents()
  2021-12-10  8:38 [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents() Jia-Ju Bai
@ 2021-12-14  7:08 ` Joseph Qi
  2021-12-14  7:19   ` Jia-Ju Bai
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Qi @ 2021-12-14  7:08 UTC (permalink / raw)
  To: Jia-Ju Bai, mark, jlbec; +Cc: ocfs2-devel, linux-kernel

Hi,

Thanks for the report. But I don't think this is a possible deadlock in
practice. Please see my comments below.

On 12/10/21 4:38 PM, Jia-Ju Bai wrote:
> Hello,
> 
> My static analysis tool reports a possible ABBA deadlock in the ocfs2 module in Linux 5.10:
> 
> ocfs2_dio_end_io_write()
>   down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A)
>   ocfs2_del_inode_from_orphan()
>     inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

Just as the variable name indicates, it is orphan dir inode, which is a
system file (something hidden inside the filesystem) and not visible for
end user.

> 
> ocfs2_move_extents()
>   inode_lock(inode); --> Line 916 (Lock B)

This is called from a ioctl from user, it a normal file inode.

Thanks,
Joseph

>   down_write(&OCFS2_I(inode)->ip_alloc_sem); --> Line 936 (Lock A)
> 
> When ocfs2_dio_end_io_write() and ocfs2_move_extents() are concurrently executed, the deadlocks 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] 4+ messages in thread

* Re: [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents()
  2021-12-14  7:08 ` Joseph Qi
@ 2021-12-14  7:19   ` Jia-Ju Bai
  0 siblings, 0 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2021-12-14  7:19 UTC (permalink / raw)
  To: Joseph Qi, mark, jlbec; +Cc: ocfs2-devel, linux-kernel



On 2021/12/14 15:08, Joseph Qi wrote:
> Hi,
>
> Thanks for the report. But I don't think this is a possible deadlock in
> practice. Please see my comments below.
>
> On 12/10/21 4:38 PM, Jia-Ju Bai wrote:
>> Hello,
>>
>> My static analysis tool reports a possible ABBA deadlock in the ocfs2 module in Linux 5.10:
>>
>> ocfs2_dio_end_io_write()
>>    down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A)
>>    ocfs2_del_inode_from_orphan()
>>      inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)
> Just as the variable name indicates, it is orphan dir inode, which is a
> system file (something hidden inside the filesystem) and not visible for
> end user.
>
>> ocfs2_move_extents()
>>    inode_lock(inode); --> Line 916 (Lock B)
> This is called from a ioctl from user, it a normal file inode.

Okay, thanks for the explanation :)


Best wishes,
Jia-Ju Bai

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

* [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents()
@ 2021-12-10  8:37 Jia-Ju Bai
  0 siblings, 0 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2021-12-10  8:37 UTC (permalink / raw)
  To: mark, jlbec, joseph.qi; +Cc: ocfs2-devel, linux-kernel

Hello,

My static analysis tool reports a possible ABBA deadlock in the ocfs2 
module in Linux 5.10:

ocfs2_dio_end_io_write()
   down_write(&oi->ip_alloc_sem); --> Line 2322 (Lock A)
   ocfs2_del_inode_from_orphan()
     inode_lock(orphan_dir_inode);  --> Line 2701 (Lock B)

ocfs2_move_extents()
   inode_lock(inode); --> Line 916 (Lock B)
   down_write(&OCFS2_I(inode)->ip_alloc_sem); --> Line 936 (Lock A)

When ocfs2_dio_end_io_write() and ocfs2_move_extents() are concurrently 
executed, the deadlocks 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] 4+ messages in thread

end of thread, other threads:[~2021-12-14  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10  8:38 [BUG] fs: ocfs2: possible ABBA deadlock in ocfs2_dio_end_io_write() and ocfs2_move_extents() Jia-Ju Bai
2021-12-14  7:08 ` Joseph Qi
2021-12-14  7:19   ` Jia-Ju Bai
  -- strict thread matches above, loose matches on Subject: below --
2021-12-10  8:37 Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®