Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] dm-integrity: unrestored superblock on recalc error in dm_integrity_resume() --
commit 1f55191efead476e43582fdac18ace4fb279e159 Author: Yang Luohan <[email protected]> dm-integrity: reject recalculation when recalc_wq was never allocated This commit checks that ic->recalc_wq is non-NULL in dm_integrity_resume() before queueing ic->recalc_work when SB_FLAG_RECALCULATING is set in the superblock. > diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c > index 6968e38888db9..deddec9de3e1b 100644 > --- a/drivers/md/dm-integrity.c > +++ b/drivers/md/dm-integrity.c > @@ -4046,6 +4046,11 @@ static void dm_integrity_resume(struct dm_target *ti) > if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) { > __u64 recalc_pos = le64_to_cpu(ic->sb->recalc_sector); > > + if (unlikely(!ic->recalc_wq)) { > + DMERR("Recalculate requested, but internal_hash is not > used"); > + dm_integrity_io_error(ic, "inconsistent superblock", > -EINVAL); > + goto skip_writes; > + } > DEBUG_print("recalc pos: %llx / %llx\n", recalc_pos, > ic->provided_data_sectors); > if (recalc_pos < ic->provided_data_sectors) { > queue_work(ic->recalc_wq, &ic->recalc_work); [Severity: Medium] Should this check run alongside superblock_changed() and restore ic->sb from ic->sb_copy before jumping to skip_writes? Checking !ic->recalc_wq at the end of dm_integrity_resume() runs after the journal replay and superblock write paths have already executed, and leaves SB_FLAG_RECALCULATING set in the in-memory ic->sb->flags. As a result, dm_integrity_status() reports recalculate enabled without internal_hash, and if the on-disk superblock is repaired while suspended, a later dm_integrity_resume() captures SB_FLAG_RECALCULATING from the stale in-memory ic->sb into flags before sync_rw_sb(ic, REQ_OP_READ) and writes it back to disk: drivers/md/dm-integrity.c:dm_integrity_resume() { ... flags = ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING); if (ic->discard_keyed) flags |= cpu_to_le32(SB_FLAG_DISCARD_KEYED); r = sync_rw_sb(ic, REQ_OP_READ); ... if ((ic->sb->flags & flags) != flags) { ic->sb->flags |= flags; r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA); ... } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
