2014-04-28 22:28:55

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: [PATCH] iommu/amd: Take mmap_sem when calling get_user_pages

From: Jay Cornwall <[email protected]>

get_user_pages requires caller to hold a read lock on mmap_sem.

Signed-off-by: Jay Cornwall <[email protected]>
Signed-off-by: Suravee Suthikulpanit <[email protected]>
---
drivers/iommu/amd_iommu_v2.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 5208828..203b2e6 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -504,8 +504,10 @@ static void do_fault(struct work_struct *work)

write = !!(fault->flags & PPR_FAULT_WRITE);

+ down_read(&fault->state->mm->mmap_sem);
npages = get_user_pages(fault->state->task, fault->state->mm,
fault->address, 1, write, 0, &page, NULL);
+ up_read(&fault->state->mm->mmap_sem);

if (npages == 1) {
put_page(page);
--
1.7.10.4