iommu: Fix two issues in iommu_copy_struct_from_user()
PATCH 1/1 iommu: Fix two issues in iommu_copy_struct_from_user()
In the review for iommu_copy_struct_to_user() helper, Matt pointed out that a NULL pointer should be rejected prior to dereferencing it:
https://lore.kernel.org/all/[email protected]
And Alok pointed out a typo at the same time:
https://lore.kernel.org/all/[email protected]
Since both issues were copied from iommu_copy_struct_from_user(), fix them first in the current header.
--- include/linux/iommu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/iommu.h +4 -4
@@ -440,10 +440,10 @@ static inline int __iommu_copy_struct_from_user( void *dst_data, const struct iommu_user_data *src_data, unsigned int data_type, size_t data_len, size_t min_len) { - if (src_data->type != data_type) - return -EINVAL; if (WARN_ON(!dst_data || !src_data)) return -EINVAL; +if (src_data->type != data_type) +return -EINVAL ;if (src_data->len < min_len || data_len < src_data->len)return -EINVAL ; return copy_struct_from_user(dst_data, data_len, src_data->uptr,
@@ -456,8 +456,8 @@ static inline int __iommu_copy_struct_from_user(* include/uapi/linux/iommufd.h * @user_data: Pointer to a struct iommu_user_data for user space data info * @data_type: The data type of the @kdst. Must match with @user_data->type -* @min_last: The last memember of the data structure @kdst points in the -* initial version. +* @min_last: The last member of the data structure @kdst points in the initial +* version. * Return 0 for success, otherwise -error. */ #define iommu_copy_struct_from_user (kdst, user_data, data_type, min_last) \
Signature · 1 line
2.43.0
Quoted 8 lines · Nicolin Chen
Since both issues were copied from
iommu_copy_struct_from_user(), fix them first in the current header.Fixes e9d36c07bb78 ("iommu: Add iommu_copy_struct_from_user helper")Signed-off-by Nicolin Chen <[email protected]>
Thanks Nicolin!
Quoted 8 lines · Nicolin Chen
Since both issues were copied from
iommu_copy_struct_from_user(), fix them first in the current header.Fixes e9d36c07bb78 ("iommu: Add iommu_copy_struct_from_user helper")Signed-off-by Nicolin Chen<[email protected]>--- include/linux/iommu.h | 8 ++++----
Thanks Nicolin!
Quoted 13 lines
From: Nicolin Chen <[email protected]>
Sent: Tuesday, April 15, 2025 3:17 AMIn the review for
iommu_copy_struct_to_user()helper, Matt pointed out that
a NULL pointer should be rejected prior to dereferencing it:
https://lore.kernel.org/all/86881827-8E2D-461C-BDA3-
[email protected]And Alok pointed out a typo at the same time:
https://lore.kernel.org/all/480536af-6830-43ce-a327-
[email protected]
Quoted 7 lines
Since both issues were copied from
iommu_copy_struct_from_user(), fix them
first in the current header.Fixes e9d36c07bb78 ("iommu: Add iommu_copy_struct_from_user helper")Signed-off-by Nicolin Chen <[email protected]>