iommufd/selftest: Rework TEST_LENGTH to test min_size explicitly
mainline inclusion from mainline-v6.7-rc1 commit 266dcae34d8f44c3bbab00e227f8b14517682bb7 category: feature bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8Y6AM CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?266dcae34d8f44c3bbab00e227f8b14517682bb7 -------------------------------- TEST_LENGTH passing ".size = sizeof(struct _struct) - 1" expects -EINVAL from "if (ucmd.user_size < op->min_size)" check in iommufd_fops_ioctl(). This has been working when min_size is exactly the size of the structure. However, if the size of the structure becomes larger than min_size, i.e. the passing size above is larger than min_size, that min_size sanity no longer works. Since the first test in TEST_LENGTH() was to test that min_size sanity routine, rework it to support a min_size calculation, rather than using the full size of the structure. Intel-SIG: 266dcae34d8f iommufd/selftest: Rework TEST_LENGTH to test min_size explicitly Backport IOMMUFD Dirty Tracking Link: https://lore.kernel.org/r/20231015074648.24185-1-nicolinc@nvidia.com Signed-off-by:Nicolin Chen <nicolinc@nvidia.com> Reviewed-by:
Kevin Tian <kevin.tian@intel.com> Signed-off-by:
Jason Gunthorpe <jgg@nvidia.com> [ jz: amend-commit-log ] Signed-off-by:
Jason Zeng <jason.zeng@intel.com>
Loading
Please sign in to comment