]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl()
authorArnd Bergmann <arnd@arndb.de>
Fri, 11 Jul 2025 08:46:51 +0000 (10:46 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 11 Jul 2025 10:05:01 +0000 (12:05 +0200)
commit42b0ef01e6b5e9c77b383d32c25a0ec2a735d08a
tree09b2ff90bc0f273520ee24a2f3cdb605404853a9
parent4a3def74d9810f4d4148a3aa17b76d2f0c0f6109
block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl()

Anders and Naresh found that the addition of the FS_IOC_GETLBMD_CAP
handling in the blockdev ioctl handler breaks all ioctls with
_IOC_NR==2, as the new command is not added to the switch but only
a few of the command bits are check.

Move the check into the blk_get_meta_cap() function itself and make
it return -ENOIOCTLCMD for any unsupported command code, including
those with a smaller size that previously returned -EINVAL.

For consistency this also drops the check for NULL 'arg' that
is really useless, as any invalid pointer should return -EFAULT.

Fixes: 9eb22f7fedfc ("fs: add ioctl to query metadata and protection info capabilities")
Link: https://lore.kernel.org/all/CA+G9fYvk9HHE5UJ7cdJHTcY6P5JKnp+_e+sdC5U-ZQFTP9_hqQ@mail.gmail.com/
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Anders Roxell <anders.roxell@linaro.org>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/20250711084708.2714436-1-arnd@kernel.org
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
block/blk-integrity.c
block/ioctl.c