From: Vasiliy Kovalev <kovalev@altlinux.org>
To: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>,
dm-devel@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
kovalev@altlinux.org
Subject: [PATCH] dm zoned: fix NULL pointer dereference in dmz_load_sb()
Date: Fri, 20 Nov 2026 21:50:37 +0300 [thread overview]
Message-ID: <20261120185037.614445-1-kovalev@altlinux.org> (raw)
When the primary super block is not valid, dmz_load_sb() searches for
the secondary one with dmz_lookup_secondary_sb(). If the search fails,
zmd->sb[1].dev is NULL, and the error is then reported with
dmz_dev_err(zmd->sb[1].dev, ...), which dereferences the device to
print its bdev:
device-mapper: zoned metadata: (ram0): Invalid meta magic (needed 0x445a4244, got 0x00000000)
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 2 UID: 0 PID: 1412 Comm: syz.1.17 Not tainted 7.4.0-rc1-next-20261104-alt-syz-box-drivers_md_bcache #1 PREEMPT(lazy)
RIP: 0010:dmz_load_sb drivers/md/dm-zoned-metadata.c:1259 [inline]
RIP: 0010:dmz_ctr_metadata+0x2389/0x4a20 drivers/md/dm-zoned-metadata.c:2897
Call Trace:
<TASK>
dmz_ctr+0xb53/0x1df0 drivers/md/dm-zoned-target.c:873
dm_table_add_target+0x7c2/0xf30 drivers/md/dm-table.c:749
populate_table drivers/md/dm-ioctl.c:1602 [inline]
table_load+0x38b/0x910 drivers/md/dm-ioctl.c:1645
ctl_ioctl+0x4d2/0xd70 drivers/md/dm-ioctl.c:2221
dm_ctl_ioctl+0x1e/0x30 drivers/md/dm-ioctl.c:2243
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl fs/ioctl.c:583 [inline]
__x64_sys_ioctl+0x18a/0x210 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x112/0x630 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x00007f443b88a829
</TASK>
Loading a "zoned" table on top of devices that carry no dm-zoned
metadata is enough to trigger it.
The secondary super block always resides on the same device as the
primary one, so report the failure against zmd->sb[0].dev, which is
always set at this point.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Fixes: 977ff73e6415 ("dm-zoned: remove the ->name field in struct dmz_dev")
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
drivers/md/dm-zoned-metadata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 094b63215882..f7aa04954d2f 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -1256,7 +1256,7 @@ static int dmz_load_sb(struct dmz_metadata *zmd)
ret = dmz_lookup_secondary_sb(zmd);
if (ret) {
- dmz_dev_err(zmd->sb[1].dev, "Read secondary super block failed");
+ dmz_dev_err(zmd->sb[0].dev, "Read secondary super block failed");
return ret;
}
--
2.50.1
reply other threads:[~2026-11-20 18:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261120185037.614445-1-kovalev@altlinux.org \
--to=kovalev@altlinux.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mpatocka@redhat.com \
--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®