From: Mikulas Patocka <mpatocka@redhat.com>
To: Aibing Chen <chenaibing@cmss.chinamobile.com>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Benjamin Marzinski <bmarzins@redhat.com>,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm-integrity: initialize free_sectors when the superblock changes on resume
Date: Mon, 16 Nov 2026 16:17:43 +0100 (CET) [thread overview]
Message-ID: <a0d2a86b-a001-9f82-1d08-fd8348688218@redhat.com> (raw)
In-Reply-To: <20261115115329.1174-1-chenaibing@cmss.chinamobile.com>
On Sun, 15 Nov 2026, Aibing Chen wrote:
> fc79aeb86a2c ("dm-integrity: validate the superblock on resume") made
> dm_integrity_resume() jump to skip_writes when the on-disk superblock was
> modified while the device was suspended. That path skips
> replay_journal(), so the journal accounting variables stay
> zero-initialized: free_sectors is 0 while journal_sections and
> journal_section_entries are nonzero.
>
> A later suspend or flush queues integrity_commit(), which calls
> pad_uncommitted() in journal mode. Its invariant
>
> journal_sections * journal_section_entries ==
> (n_uncommitted_sections + n_committed_sections) *
> journal_section_entries + free_sectors
>
> no longer holds because the right-hand side evaluates to 0, and WARN_ON
> fires.
>
> Restore free_sectors on that error path, as replay_journal() does for the
> normal resume. The section counters are already zero and nothing will be
> committed, since the device is marked failed.
>
> Reported-by: syzbot+94dac3c75477e184f0b0@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=94dac3c75477e184f0b0
> Fixes: fc79aeb86a2c ("dm-integrity: validate the superblock on resume")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
Hi
This should be already fixed by the commit
e5e03918fbec31f0c896f4f43c2bd2aadf35d43d ("dm-integrity: don't attempt to
commit journal on disabled device")
Mikulas
> ---
> drivers/md/dm-integrity.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
> index 802b37761..6ab305b60 100644
> --- a/drivers/md/dm-integrity.c
> +++ b/drivers/md/dm-integrity.c
> @@ -3915,6 +3915,13 @@ static void dm_integrity_resume(struct dm_target *ti)
> memcpy(ic->sb, ic->sb_copy, sizeof(struct superblock));
> DMERR("The superblock was changed while the device was suspended");
> dm_integrity_io_error(ic, "superblock check", -EINVAL);
> + /*
> + * replay_journal() is skipped below, so the journal accounting stays
> + * zero-initialized and pad_uncommitted() would trigger its WARN_ON.
> + * Restore the free sector count; the section counters are already zero
> + * and nothing is committed because the device is marked failed.
> + */
> + ic->free_sectors = ic->journal_entries;
> goto skip_writes;
> }
>
>
>
prev parent reply other threads:[~2026-11-16 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 11:53 Aibing Chen
2026-11-16 15:17 ` Mikulas Patocka [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=a0d2a86b-a001-9f82-1d08-fd8348688218@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=chenaibing@cmss.chinamobile.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®