]> git.baikalelectronics.ru Git - kernel.git/commit
dm integrity: fix integrity recalculation that is improperly skipped
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 23 Jul 2020 14:42:09 +0000 (10:42 -0400)
committerMike Snitzer <snitzer@redhat.com>
Thu, 23 Jul 2020 18:39:37 +0000 (14:39 -0400)
commit2a653e97392e0cfbcf6f07779d6b296307c7b0d5
tree70d70eb0c263e130f3ec662cc6c1248cc8da77e6
parent60be5f5d2911ffbf0a5425f8902730b2fbc0f5a5
dm integrity: fix integrity recalculation that is improperly skipped

Commit 31cbd4abc276f9ca77ef2142636a49f4e7cd3fe6 ("dm: report suspended
device during destroy") broke integrity recalculation.

The problem is dm_suspended() returns true not only during suspend,
but also during resume. So this race condition could occur:
1. dm_integrity_resume calls queue_work(ic->recalc_wq, &ic->recalc_work)
2. integrity_recalc (&ic->recalc_work) preempts the current thread
3. integrity_recalc calls if (unlikely(dm_suspended(ic->ti))) goto unlock_ret;
4. integrity_recalc exits and no recalculating is done.

To fix this race condition, add a function dm_post_suspending that is
only true during the postsuspend phase and use it instead of
dm_suspended().

Signed-off-by: Mikulas Patocka <mpatocka redhat com>
Fixes: 31cbd4abc276 ("dm: report suspended device during destroy")
Cc: stable vger kernel org # v4.18+
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-integrity.c
drivers/md/dm.c
include/linux/device-mapper.h