Skip to content

loop: Fix oops and possible deadlocks

Jan Kara linux-block 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest16 patches 5 repliesIn review
  2. v215 patches 8 repliesSuperseded
  3. v114 patches 2 repliesSuperseded

Changes in v3 from the cover letter

* Rebase on top of 4.20-rc1
* Add patch to stop fooling lockdep about loop_ctl_mutex

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16block/loop: Don't grab "struct file" for vfs_getattr() operation.drivers/block/loop.c+5 -50 replies
2/16block/loop: Use global lock for ioctl() operation.drivers/block/loop.c drivers/block/loop.h+29 -300 replies
3/16loop: Fold __loop_release into loop_releasedrivers/block/loop.c+7 -90 replies
4/16loop: Get rid of loop_index_mutexdrivers/block/loop.c+20 -210 replies
5/16loop: Push lo_ctl_mutex down into individual ioctlsdrivers/block/loop.c+63 -250 replies
6/16loop: Split setting of lo_state from loop_clr_fddrivers/block/loop.c+31 -210 replies
7/16loop: Push loop_ctl_mutex down into loop_clr_fd()drivers/block/loop.c+29 -200 replies
8/16loop: Push loop_ctl_mutex down to loop_get_status()drivers/block/loop.c+10 -270 replies
9/16loop: Push loop_ctl_mutex down to loop_set_status()drivers/block/loop.c+25 -260 replies
10/16loop: Push loop_ctl_mutex down to loop_set_fd()drivers/block/loop.c+14 -120 replies
11/16loop: Push loop_ctl_mutex down to loop_change_fd()drivers/block/loop.c+11 -110 replies
12/16loop: Move special partition reread handling in loop_clr_fd()drivers/block/loop.c+19 -140 replies
13/16loop: Move loop_reread_partitions() out of loop_ctl_mutexdrivers/block/loop.c+14 -50 replies
14/16loop: Fix deadlock when calling blkdev_reread_part()drivers/block/loop.c+16 -120 replies
15/16loop: Avoid circular locking dependency between loop_ctl_mutex and bd_mutexdrivers/block/loop.c+15 -110 replies
16/16loop: Get rid of 'nested' acquisition of loop_ctl_mutexdrivers/block/loop.c+6 -60 replies

Reviews trailers per patch

2 of 16 patches have a Reviewed-by or Acked-by.

PatchJan Kara
1/16R-b
2/16R-b
3/16
4/16
5/16
6/16
7/16
8/16
9/16
10/16
11/16
12/16
13/16
14/16
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH 0/16 v3] loop: Fix oops and possible deadlocks

Hi,

this patch series fixes oops and possible deadlocks as reported by syzbot [1] [2]. The second patch in the series (from Tetsuo) fixes the oops, the remaining patches are cleaning up the locking in the loop driver so that we can in the end reasonably easily switch to rereading partitions without holding mutex protecting the loop device.

I have tested the patches by creating, deleting, modifying loop devices, and by running loop blktests (as well as creating new ones with the load syzkaller has used to detect the problem). Review is welcome but I think the patches are fine to go as far as I'm concerned! Jens, can you please pick them up?

Changes since v1:
* Added patch moving fput() calls in loop_change_fd() from under loop_ctl_mutex
* Fixed bug in loop_control_ioctl() where it failed to return error properly

Changes since v2:
* Rebase on top of 4.20-rc1
* Add patch to stop fooling lockdep about loop_ctl_mutex

Honza

[1] https://syzkaller.appspot.com/bug?id=f3cfe26e785d85f9ee259f385515291d21bd80a3
[2] https://syzkaller.appspot.com/bug?id=bf154052f0eea4bc7712499e4569505907d15889