diff options
| author | 2026-09-22 12:46:06 +0800 | |
|---|---|---|
| committer | 2026-09-23 11:23:27 +0800 | |
| commit | ae5f89b23cb88667cfa1273b42d6a551db9c651e (patch) | |
| tree | f05962a35595dd9c2f26d1ed7b63ee4af2ced618 /scripts/Makefile.thinlto | |
| parent | md/raid: use assign_bit() where applicable (diff) | |
md: validate bblog_size when loading v1.x badblocks metadata
In super_1_load(), when the on-disk feature_map does not have
MD_FEATURE_BAD_BLOCKS set but sb->bblog_offset is non-zero,
rdev->badblocks.shift is initialized to 0 without validating
sb->bblog_size. The same field is validated in the
MD_FEATURE_BAD_BLOCKS branch ("sectors > (PAGE_SIZE / 512)"), but this
branch bypasses that check.
A forged on-disk superblock (malicious storage device or crafted
image) can therefore carry an oversized sb->bblog_size. When bad
blocks are later recorded, super_1_sync() sets bb->size from
sb->bblog_size and md_write_metadata() issues a bio larger than the
single rdev->bb_page, reading beyond the page and leaking kernel
memory contents to disk.
sb->bblog_size is never modified by the kernel between load and sync,
and the MD_FEATURE_BAD_BLOCKS branch already validates it, so checking
it in this branch is sufficient to cover both paths.
Fix this by rejecting an oversized sb->bblog_size with -EINVAL,
matching the existing check in the MD_FEATURE_BAD_BLOCKS branch.
Fixes: 2699b67223ac ("md: load/store badblock list from v1.x metadata")
Cc: stable@vger.kernel.org
Signed-off-by: Yuchao Zhang <ndaugoing@gmail.com>
Link: https://patch.msgid.link/20260922044606.30774-1-ndaugoing@gmail.com
Signed-off-by: Yu Kuai <yukuai@fygo.io>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
