From: Yu Junzhe <junzheyu1@gmail.com>
To: Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>,
Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [BUG] dm: unbounded recursion in dm_blk_ioctl via cyclic DM stacking
Date: Tue, 18 Aug 2026 07:56:27 +0000 [thread overview]
Message-ID: <20260818075627.322-1-junzheyu1@gmail.com> (raw)
Hello,
I am reporting unbounded recursion in dm_blk_ioctl(): it forwards a block
ioctl to the underlying device with no depth or cycle guard. A two-device
DM-on-DM cycle then re-enters dm_blk_ioctl until the kernel stack is
exhausted.
Summary
=======
dm_prepare_ioctl() lets the single target substitute bdev via
prepare_ioctl. dm_blk_ioctl() then calls that disk's fops->ioctl with
the original cmd/arg:
r = dm_prepare_ioctl(md, &srcu_idx, &bdev);
...
r = bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
linear_prepare_ioctl / flakey_prepare_ioctl just set *bdev to the
underlying device when sizes match. When that device is another DM
disk, fops->ioctl is dm_blk_ioctl again.
Table load rejects only a device mapped onto itself
(dm_get_device: dev == disk_devt(t->md->disk)). A->B->A is accepted.
bd_link_disk_holder rejects only a disk holding itself.
Ordinary BLKGETSIZE* ioctls on the same cycle return cleanly (handled
in the block layer). A DM-style ioctl (DM_VERSION) on the mapped
block fd is not handled there and is forwarded unbounded.
The shipped PoC uses linear + flakey. linear<->linear is expected to
recurse the same way via linear_prepare_ioctl.
Affected
========
- Confirmed on Linux 6.6.144 (da47cbc254661aa66d61ef061485a7080305c4be),
stack-protector guest
- Still present on torvalds/linux master as of 2026-08-18: dm_blk_ioctl
still forwards with no depth/cycle check; dm_get_device still only
rejects self-map. The later prepare_ioctl forward flag is for
target-local handling, not cycle detection (linear still always
forwards)
- Files: drivers/md/dm.c, drivers/md/dm-linear.c, drivers/md/dm-table.c
- Config: CONFIG_DM=y (CONFIG_DM_FLAKEY=y for the shipped PoC topology)
Crash excerpt (from minimized PoC)
==================================
BUG: TASK stack guard page was hit at ...
CPU: 0 PID: 219 Comm: repro Not tainted 6.6.144 #1
RIP: 0010:dm_prepare_ioctl+0x10/0x100
Call Trace:
<TASK>
dm_blk_ioctl+0x4d/0xe0
dm_blk_ioctl+0x78/0xe0
dm_blk_ioctl+0x78/0xe0
... (dozens more recursive dm_blk_ioctl frames)
</TASK>
Kernel panic - not syncing: Fatal exception
Full oops and a self-contained Docker/QEMU reproducer (poc.c) are
available on request.
I am happy to test patches or send the reproducer package.
Thanks,
Yu Junzhe
FuzzAnything <fuzzanything@gmail.com>
next reply other threads:[~2026-08-18 7:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 7:56 Yu Junzhe [this message]
2026-08-18 9:22 ` [BUG] dm: unbounded recursion in dm_blk_ioctl via cyclic DM stacking Mikulas Patocka
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=20260818075627.322-1-junzheyu1@gmail.com \
--to=junzheyu1@gmail.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.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 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.