Patch "iommu/sva: Fix signedness bug in iommu_sva_alloc_pasid()" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iommu/sva: Fix signedness bug in iommu_sva_alloc_pasid()

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iommu-sva-fix-signedness-bug-in-iommu_sva_alloc_pasi.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d7bf48d29d77eb138f5bacd1a9c2891e60d7a754
Author: Dan Carpenter <error27@xxxxxxxxx>
Date:   Thu Apr 6 11:55:31 2023 +0300

    iommu/sva: Fix signedness bug in iommu_sva_alloc_pasid()
    
    [ Upstream commit c20ecf7bb6153149b81a9277eda23398957656f2 ]
    
    The ida_alloc_range() function returns negative error codes on error.
    On success it returns values in the min to max range (inclusive).  It
    never returns more then INT_MAX even if "max" is higher.  It never
    returns values in the 0 to (min - 1) range.
    
    The bug is that "min" is an unsigned int so negative error codes will
    be promoted to high positive values errors treated as success.
    
    Fixes: 1a14bf0fc7ed ("iommu/sva: Use GFP_KERNEL for pasid allocation")
    Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
    Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/6b32095d-7491-4ebb-a850-12e96209eaaf@kili.mountain
    Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
index 3ebd4b6586b3e..05c0fb2acbc44 100644
--- a/drivers/iommu/iommu-sva.c
+++ b/drivers/iommu/iommu-sva.c
@@ -34,8 +34,9 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma
 	}
 
 	ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL);
-	if (ret < min)
+	if (ret < 0)
 		goto out;
+
 	mm->pasid = ret;
 	ret = 0;
 out:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux