Skip to content

Commit 4ed319c

Browse files
Mikulas Patockasnitm
authored andcommitted
dm integrity: fix deadlock with overlapping I/O
dm-integrity will deadlock if overlapping I/O is issued to it, the bug was introduced by commit 724376a ("dm integrity: implement fair range locks"). Users rarely use overlapping I/O so this bug went undetected until now. Fix this bug by correcting, likely cut-n-paste, typos in ranges_overlap() and also remove a flawed ranges_overlap() check in remove_range_unlocked(). This condition could leave unprocessed bios hanging on wait_list forever. Cc: stable@vger.kernel.org # v4.19+ Fixes: 724376a ("dm integrity: implement fair range locks") Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent bcb4443 commit 4ed319c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/md/dm-integrity.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ static void copy_from_journal(struct dm_integrity_c *ic, unsigned section, unsig
913913
static bool ranges_overlap(struct dm_integrity_range *range1, struct dm_integrity_range *range2)
914914
{
915915
return range1->logical_sector < range2->logical_sector + range2->n_sectors &&
916-
range2->logical_sector + range2->n_sectors > range2->logical_sector;
916+
range1->logical_sector + range1->n_sectors > range2->logical_sector;
917917
}
918918

919919
static bool add_new_range(struct dm_integrity_c *ic, struct dm_integrity_range *new_range, bool check_waiting)
@@ -959,8 +959,6 @@ static void remove_range_unlocked(struct dm_integrity_c *ic, struct dm_integrity
959959
struct dm_integrity_range *last_range =
960960
list_first_entry(&ic->wait_list, struct dm_integrity_range, wait_entry);
961961
struct task_struct *last_range_task;
962-
if (!ranges_overlap(range, last_range))
963-
break;
964962
last_range_task = last_range->task;
965963
list_del(&last_range->wait_entry);
966964
if (!add_new_range(ic, last_range, false)) {

0 commit comments

Comments
 (0)