Re: [BUG] dm: unbounded recursion in dm_blk_ioctl via cyclic DM stacking

From: Mikulas Patocka

Date: Tue Aug 18 2026 - 05:22:38 EST




On Tue, 18 Aug 2026, Yu Junzhe wrote:

> 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.

Hi

There is also unbounded recursion in bio_endio when stacking bio-based
drivers. Many years ago I tried to fix it, but there was no intereset in
fixing it.

If you work with block maintainers to fix the bio_endio recursion, I can
fix the dm_blk_ioctl case.

> 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.

Regarding A->B->A stacking - the user just shouldn't do recursive
stacking.

Mikulas