]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dm: fix unlocked test for dm_suspended_md
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 8 Jan 2026 19:55:08 +0000 (20:55 +0100)
committerMikulas Patocka <mpatocka@redhat.com>
Wed, 14 Jan 2026 12:12:02 +0000 (13:12 +0100)
The function dm_blk_report_zones tests if the device is suspended with
the "dm_suspended_md" call. However, this function is called without
holding any locks, so the device may be suspended just after it.

Move the call to dm_suspended_md after dm_get_live_table, so that the
device can't be suspended after the suspended state was tested.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 37f53a2c60d0 ("dm: fix dm_blk_report_zones")
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
drivers/md/dm-zone.c

index c95e417194b33cbab6fa9547b77ec947b3369988..bc4e45862a220457a8d7012c87f3516bfe66f77d 100644 (file)
@@ -60,11 +60,13 @@ int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
                 * Zone revalidation during __bind() is in progress, but this
                 * call is from a different process
                 */
-               if (dm_suspended_md(md))
-                       return -EAGAIN;
-
                map = dm_get_live_table(md, &srcu_idx);
                put_table = true;
+
+               if (dm_suspended_md(md)) {
+                       ret = -EAGAIN;
+                       goto do_put_table;
+               }
        } else {
                /* Zone revalidation during __bind() */
                map = zone_revalidate_map;
@@ -79,6 +81,7 @@ int dm_blk_report_zones(struct gendisk *disk, sector_t sector,
                ret = dm_blk_do_report_zones(md, map, nr_zones, &dm_args);
        }
 
+do_put_table:
        if (put_table)
                dm_put_live_table(md, srcu_idx);