* [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow
@ 2020-06-24 8:41 Suravee Suthikulpanit
2020-06-24 9:09 ` Greg KH
2020-06-24 11:55 ` Joerg Roedel
0 siblings, 2 replies; 5+ messages in thread
From: Suravee Suthikulpanit @ 2020-06-24 8:41 UTC (permalink / raw)
To: gregkh; +Cc: iommu, stable
Currently, an integer is used to specify the size in unmap_sg().
With 2GB worth of pages (512k 4k pages), it requires 31 bits
(i.e. (1 << 19) << 12), which overflows the integer, and ends up
unmapping more pages than intended. Subsequently, this results in
IO_PAGE_FAULT.
Uses size_t instead of int to pass parameter to __unmap_single().
Please note that this patch is only for the stable-kernels tree
because the commit be62dbf554c5 ("iommu/amd: Convert AMD iommu driver
to the dma-iommu api"), which removes the function unmap_sg()
was introduced in v5.5. This patch is not applicable in subsequent
kernel versions.
Cc: stable@vger.kernel.org
Cc: iommu@lists.linux-foundation.org
Reported-by: Robert Lippert <rlippert@google.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
drivers/iommu/amd_iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 32de8e7bb8b4..7adc021932b8 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2670,7 +2670,7 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
struct protection_domain *domain;
struct dma_ops_domain *dma_dom;
unsigned long startaddr;
- int npages;
+ size_t npages;
domain = get_domain(dev);
if (IS_ERR(domain))
--
2.17.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow
2020-06-24 8:41 [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow Suravee Suthikulpanit
@ 2020-06-24 9:09 ` Greg KH
2020-06-24 11:58 ` Joerg Roedel
2020-06-24 11:55 ` Joerg Roedel
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-06-24 9:09 UTC (permalink / raw)
To: Suravee Suthikulpanit; +Cc: iommu, stable
On Wed, Jun 24, 2020 at 08:41:21AM +0000, Suravee Suthikulpanit wrote:
> Currently, an integer is used to specify the size in unmap_sg().
> With 2GB worth of pages (512k 4k pages), it requires 31 bits
> (i.e. (1 << 19) << 12), which overflows the integer, and ends up
> unmapping more pages than intended. Subsequently, this results in
> IO_PAGE_FAULT.
>
> Uses size_t instead of int to pass parameter to __unmap_single().
>
> Please note that this patch is only for the stable-kernels tree
> because the commit be62dbf554c5 ("iommu/amd: Convert AMD iommu driver
> to the dma-iommu api"), which removes the function unmap_sg()
> was introduced in v5.5. This patch is not applicable in subsequent
> kernel versions.
So what exact stable kernel version(s) do you want to see this patch
applied to?
thanks,
greg k-h
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow
2020-06-24 8:41 [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow Suravee Suthikulpanit
2020-06-24 9:09 ` Greg KH
@ 2020-06-24 11:55 ` Joerg Roedel
1 sibling, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2020-06-24 11:55 UTC (permalink / raw)
To: Suravee Suthikulpanit; +Cc: gregkh, iommu, stable
On Wed, Jun 24, 2020 at 08:41:21AM +0000, Suravee Suthikulpanit wrote:
> Currently, an integer is used to specify the size in unmap_sg().
> With 2GB worth of pages (512k 4k pages), it requires 31 bits
> (i.e. (1 << 19) << 12), which overflows the integer, and ends up
> unmapping more pages than intended. Subsequently, this results in
> IO_PAGE_FAULT.
>
> Uses size_t instead of int to pass parameter to __unmap_single().
>
> Please note that this patch is only for the stable-kernels tree
> because the commit be62dbf554c5 ("iommu/amd: Convert AMD iommu driver
> to the dma-iommu api"), which removes the function unmap_sg()
> was introduced in v5.5. This patch is not applicable in subsequent
> kernel versions.
>
> Cc: stable@vger.kernel.org
> Cc: iommu@lists.linux-foundation.org
> Reported-by: Robert Lippert <rlippert@google.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow
2020-06-24 9:09 ` Greg KH
@ 2020-06-24 11:58 ` Joerg Roedel
2020-07-30 7:28 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2020-06-24 11:58 UTC (permalink / raw)
To: Greg KH; +Cc: iommu, stable
Hi Greg,
On Wed, Jun 24, 2020 at 11:09:06AM +0200, Greg KH wrote:
> So what exact stable kernel version(s) do you want to see this patch
> applied to?
It is needed in kernels <= v5.4. Linux v5.5 has replaced the code with
the bug.
Joerg
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow
2020-06-24 11:58 ` Joerg Roedel
@ 2020-07-30 7:28 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2020-07-30 7:28 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, stable
On Wed, Jun 24, 2020 at 01:58:27PM +0200, Joerg Roedel wrote:
> Hi Greg,
>
> On Wed, Jun 24, 2020 at 11:09:06AM +0200, Greg KH wrote:
> > So what exact stable kernel version(s) do you want to see this patch
> > applied to?
>
> It is needed in kernels <= v5.4. Linux v5.5 has replaced the code with
> the bug.
This doesn't apply to any older kernels that I can see :(
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-30 7:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 8:41 [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow Suravee Suthikulpanit
2020-06-24 9:09 ` Greg KH
2020-06-24 11:58 ` Joerg Roedel
2020-07-30 7:28 ` Greg KH
2020-06-24 11:55 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).