* [PATCH] dm: fix unlocked test for dm_suspended_md
@ 2026-01-08 19:55 Mikulas Patocka
2026-01-08 20:41 ` Benjamin Marzinski
0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2026-01-08 19:55 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, Benjamin Marzinski; +Cc: dm-devel
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")
---
drivers/md/dm-zone.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: linux-2.6/drivers/md/dm-zone.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-zone.c 2026-01-06 15:55:41.000000000 +0100
+++ linux-2.6/drivers/md/dm-zone.c 2026-01-06 22:55:36.000000000 +0100
@@ -60,11 +60,13 @@ int dm_blk_report_zones(struct gendisk *
* 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 *
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);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] dm: fix unlocked test for dm_suspended_md
2026-01-08 19:55 [PATCH] dm: fix unlocked test for dm_suspended_md Mikulas Patocka
@ 2026-01-08 20:41 ` Benjamin Marzinski
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Marzinski @ 2026-01-08 20:41 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: Alasdair Kergon, Mike Snitzer, dm-devel
On Thu, Jan 08, 2026 at 08:55:08PM +0100, Mikulas Patocka wrote:
> 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 | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/drivers/md/dm-zone.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-zone.c 2026-01-06 15:55:41.000000000 +0100
> +++ linux-2.6/drivers/md/dm-zone.c 2026-01-06 22:55:36.000000000 +0100
> @@ -60,11 +60,13 @@ int dm_blk_report_zones(struct gendisk *
> * 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 *
> 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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-08 20:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 19:55 [PATCH] dm: fix unlocked test for dm_suspended_md Mikulas Patocka
2026-01-08 20:41 ` Benjamin Marzinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox