[LTP] [PATCH] block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl()

Christoph Hellwig hch@infradead.org
Thu Jul 10 10:14:33 CEST 2025


On Thu, Jul 10, 2025 at 10:00:48AM +0200, Christian Brauner wrote:
> +       switch (_IOC_NR(cmd)) {
> +       case _IOC_NR(FS_IOC_GETLBMD_CAP):
> +               if (_IOC_DIR(cmd) != _IOC_DIR(FS_IOC_GETLBMD_CAP))
> +                       break;
> +               if (_IOC_TYPE(cmd) != _IOC_TYPE(FS_IOC_GETLBMD_CAP))
> +                       break;
> +               if (_IOC_NR(cmd) != _IOC_NR(FS_IOC_GETLBMD_CAP))
> +                       break;
> +               if (_IOC_SIZE(cmd) < LBMD_SIZE_VER0)
> +                       break;
> +               if (_IOC_SIZE(cmd) > PAGE_SIZE)
> +                       break;
> +               return blk_get_meta_cap(bdev, cmd, argp);
> +       }

Yikes.  I really don't get why we're trying change the way how ioctls
worked forever.  We can and usually do use the size based macro already.
And when we introduce a new size (which should happen rarely), we add a
new entry to the switch using the normal _IO* macros, and either
rename the struct, or use offsetofend in the _IO* entry for the old one.

Just in XFS which I remember in detail we've done that to extend
structures in backwards compatible ways multiple times.


More information about the ltp mailing list