Commit 139c631d authored by Nicolin Chen's avatar Nicolin Chen Committed by Jason Zeng
Browse files

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: default avatarNicolin Chen <nicolinc@nvidia.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
[ jz: amend-commit-log ]
Signed-off-by: default avatarJason Zeng <jason.zeng@intel.com>
parent d7ed92ba
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment