From: Yuchao Zhang <ndaugoing@gmail.com>
To: Yu Kuai <yukuai@fygo.io>, Song Liu <song@kernel.org>
Cc: Xiao Ni <xni@redhat.com>, NeilBrown <neilb@suse.de>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Yuchao Zhang <ndaugoing@gmail.com>
Subject: Re: [PATCH 1/2] md: fix bblog_size-driven OOB read in super_1_load() and super_1_sync()
Date: Tue, 22 Sep 2026 12:45:56 +0800 [thread overview]
Message-ID: <20260922044556.30746-1-ndaugoing@gmail.com> (raw)
In-Reply-To: <fad92649-e362-443a-93ea-205b11247e6d@fygo.io>
Hi Kuai,
Thanks for the review.
The 'else if (sb->bblog_offset != 0)' branch handles the valid on-disk
state where bblog space was reserved at array creation but no bad blocks
have been recorded yet (MD_FEATURE_BAD_BLOCKS clear). A corrupted or
forged superblock - hardware fault, fuzzing, or a malicious shared disk -
can carry an oversized bblog_size (e.g. 0xFFFF) in that state, bypassing
the existing validation in the MD_FEATURE_BAD_BLOCKS branch.
When the first bad block is later recorded, super_1_sync() copies
sb->bblog_size into bb->size, and md_write_metadata() then builds a bio
larger than the backing rdev->bb_page, reading past it and leaking kernel
memory contents to disk.
You are right that fixing super_1_load() alone is sufficient: the kernel
never modifies sb->bblog_size between load and sync, and with the -EINVAL
check the device never enters the array, so super_1_sync() is never
reached with an oversized value. v2 keeps only the super_1_load()
validation.
Thanks,
Yuchao
next prev parent reply other threads:[~2026-09-22 4:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 8:38 [PATCH 0/2] md: fix bblog_size-driven OOB read in md_write_metadata() zjamg
2026-09-17 8:38 ` [PATCH 1/2] md: fix bblog_size-driven OOB read in super_1_load() and super_1_sync() zjamg
2026-09-20 11:50 ` yu kuai
2026-09-22 4:45 ` Yuchao Zhang [this message]
2026-09-22 4:46 ` [PATCH v2] md: validate bblog_size when loading v1.x badblocks metadata Yuchao Zhang
2026-09-17 8:38 ` [PATCH 2/2] md: add defensive bounds check for bio in md_write_metadata() zjamg
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=20260922044556.30746-1-ndaugoing@gmail.com \
--to=ndaugoing@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xni@redhat.com \
--cc=yukuai@fygo.io \
/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®