]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm-verity: fix prefetch-vs-suspend race
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 28 Mar 2025 15:17:45 +0000 (16:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 20 Apr 2025 08:18:21 +0000 (10:18 +0200)
commit 2de510fccbca3d1906b55f4be5f1de83fa2424ef upstream.

There's a possible race condition in dm-verity - the prefetch work item
may race with suspend and it is possible that prefetch continues to run
while the device is suspended. Fix this by calling flush_workqueue and
dm_bufio_client_reset in the postsuspend hook.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-verity-target.c

index 47d595f6a76e57e0864ac3428434aa9862b12745..23162dd30732b9beb82f7a71a8f298626e6428f1 100644 (file)
@@ -796,6 +796,13 @@ static int verity_map(struct dm_target *ti, struct bio *bio)
        return DM_MAPIO_SUBMITTED;
 }
 
+static void verity_postsuspend(struct dm_target *ti)
+{
+       struct dm_verity *v = ti->private;
+       flush_workqueue(v->verify_wq);
+       dm_bufio_client_reset(v->bufio);
+}
+
 /*
  * Status: V (valid) or C (corruption found)
  */
@@ -1766,6 +1773,7 @@ static struct target_type verity_target = {
        .ctr            = verity_ctr,
        .dtr            = verity_dtr,
        .map            = verity_map,
+       .postsuspend    = verity_postsuspend,
        .status         = verity_status,
        .prepare_ioctl  = verity_prepare_ioctl,
        .iterate_devices = verity_iterate_devices,