mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user()
@ 2025-04-14 19:16 Nicolin Chen
  2025-04-15  4:21 ` Matt Ochs
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolin Chen @ 2025-04-14 19:16 UTC (permalink / raw)
  To: joro, jgg, kevin.tian
  Cc: will, robin.murphy, yi.l.liu, iommu, linux-kernel, mochs, alok.a.tiwari

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/86881827-8E2D-461C-BDA3-FA8FD14C343C@nvidia.com

And Alok pointed out a typo at the same time:
https://lore.kernel.org/all/480536af-6830-43ce-a327-adbd13dc3f1d@oracle.com

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")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 include/linux/iommu.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ccce8a751e2a..3a8d35d41fda 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -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) \
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user()
  2025-04-14 19:16 [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user() Nicolin Chen
@ 2025-04-15  4:21 ` Matt Ochs
  2025-04-15  5:21 ` ALOK TIWARI
  2025-04-15  6:27 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: Matt Ochs @ 2025-04-15  4:21 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: joro, Jason Gunthorpe, Kevin Tian, Will Deacon, robin.murphy,
	yi.l.liu, iommu, linux-kernel, alok.a.tiwari

> On Apr 14, 2025, at 2:16 PM, Nicolin Chen <nicolinc@nvidia.com> wrote:
> 
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>

Thanks Nicolin!

Reviewed-by: Matthew R. Ochs <mochs@nvidia.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user()
  2025-04-14 19:16 [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user() Nicolin Chen
  2025-04-15  4:21 ` Matt Ochs
@ 2025-04-15  5:21 ` ALOK TIWARI
  2025-04-15  6:27 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: ALOK TIWARI @ 2025-04-15  5:21 UTC (permalink / raw)
  To: Nicolin Chen, joro, jgg, kevin.tian
  Cc: will, robin.murphy, yi.l.liu, iommu, linux-kernel, mochs



On 15-04-2025 00:46, Nicolin Chen wrote:
> 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")
> Cc:stable@vger.kernel.org
> Signed-off-by: Nicolin Chen<nicolinc@nvidia.com>
> ---
>   include/linux/iommu.h | 8 ++++----

Thanks Nicolin!

Acked-by: Alok Tiwari <alok.a.tiwari@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user()
  2025-04-14 19:16 [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user() Nicolin Chen
  2025-04-15  4:21 ` Matt Ochs
  2025-04-15  5:21 ` ALOK TIWARI
@ 2025-04-15  6:27 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2025-04-15  6:27 UTC (permalink / raw)
  To: Nicolin Chen, joro, jgg
  Cc: will, robin.murphy, Liu, Yi L, iommu, linux-kernel, mochs, alok.a.tiwari

> From: Nicolin Chen <nicolinc@nvidia.com>
> Sent: Tuesday, April 15, 2025 3:17 AM
> 
> 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/86881827-8E2D-461C-BDA3-
> FA8FD14C343C@nvidia.com
> 
> And Alok pointed out a typo at the same time:
> https://lore.kernel.org/all/480536af-6830-43ce-a327-
> adbd13dc3f1d@oracle.com
> 
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-15  6:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-14 19:16 [PATCH rc] iommu: Fix two issues in iommu_copy_struct_from_user() Nicolin Chen
2025-04-15  4:21 ` Matt Ochs
2025-04-15  5:21 ` ALOK TIWARI
2025-04-15  6:27 ` Tian, Kevin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®