Skip to content

Commit 2de510f

Browse files
author
Mikulas Patocka
committed
dm-verity: fix prefetch-vs-suspend race
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 <[email protected]> Cc: [email protected]
1 parent 8bde103 commit 2de510f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/md/dm-verity-target.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,13 @@ static int verity_map(struct dm_target *ti, struct bio *bio)
836836
return DM_MAPIO_SUBMITTED;
837837
}
838838

839+
static void verity_postsuspend(struct dm_target *ti)
840+
{
841+
struct dm_verity *v = ti->private;
842+
flush_workqueue(v->verify_wq);
843+
dm_bufio_client_reset(v->bufio);
844+
}
845+
839846
/*
840847
* Status: V (valid) or C (corruption found)
841848
*/
@@ -1806,6 +1813,7 @@ static struct target_type verity_target = {
18061813
.ctr = verity_ctr,
18071814
.dtr = verity_dtr,
18081815
.map = verity_map,
1816+
.postsuspend = verity_postsuspend,
18091817
.status = verity_status,
18101818
.prepare_ioctl = verity_prepare_ioctl,
18111819
.iterate_devices = verity_iterate_devices,

0 commit comments

Comments
 (0)