iommu/sva: fix signedness bug in iommu_sva_alloc_pasid()
Subsystems (2)
PATCH 1/1 iommu/sva: fix signedness bug in iommu_sva_alloc_pasid()
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.
--- drivers/iommu/iommu-sva.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/iommu-sva.c +2 -1
@@ -33,8 +33,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:
Signature · 1 line
2.39.1
Quoted 10 lines · Dan Carpenter
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 thenINT_MAXeven 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<[email protected]>
Best regards,
baolu
Ping!
regards,
dan carpenter
Quoted 31 lines · Dan Carpenter
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 thenINT_MAXeven 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 <[email protected]>--- drivers/iommu/iommu-sva.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iommu/iommu-sva.c +2
-1@@ -33,8 +33,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:Signature · 1 line
2.39.1
Will Deacon
maintainerQuoted 1 line · Dan Carpenter
Ping!
Ah, Joerg isn't on CC. Fixing that now...
Will
Quoted 32 lines · Dan Carpenter
Quoted 31 lines
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 thenINT_MAXeven 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 <[email protected]>--- drivers/iommu/iommu-sva.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iommu/iommu-sva.c +2
-1@@ -33,8 +33,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:Signature · 1 line
2.39.1
Quoted 5 lines · Will Deacon
Quoted 1 line · Dan Carpenter
Ping!
Ah, Joerg isn't on CC. Fixing that now...
Sorry! I use a script to send patches and for a while if the patch had a Fixes tag then my script would remove the top name listed from get_maintainer.pl. Doh!
I should probably resend this?
regards,
dan carpenter
Joerg Roedel
maintainerQuoted 1 line · Dan Carpenter
I should probably resend this?
No, just applied it, thanks.