From: sashiko-bot@kernel.org
To: "Yang Luohan" <ylh440104@gmail.com>,
"Mikulas Patocka" <mpatocka@redhat.com>
Cc: dm-devel@lists.linux.dev, "Mike Snitzer" <snitzer@kernel.org>,
"Benjamin Marzinski" <bmarzins@redhat.com>
Subject: Re: [PATCH] dm-integrity: reject recalculation when recalc_wq was never allocated
Date: Fri, 20 Nov 2026 15:44:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-225476@kernel.org> (raw)
In-Reply-To: <179518869380.2402.12815883988413214937@gmail.com>
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 <ylh440104@gmail.com>
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/179518869380.2402.12815883988413214937@gmail.com?part=1
prev parent reply other threads:[~2026-11-20 15:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 15:31 [PATCH] dm-integrity: reject recalculation when recalc_wq was never allocated Yang Luohan
2026-11-20 15:44 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-225476@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=mpatocka@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=snitzer@kernel.org \
--cc=ylh440104@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.