[PATCH 4/8] mm/gup: add an assertion that the mmap lock is locked

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

 



This is always required, but we can't have a proper unguarded assertion
because of a shortcut in fork. So, cover as much as we can for now.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
---
 mm/gup.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index 9e332e3f6ea8e2..d203e268793b9c 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1350,6 +1350,14 @@ static __always_inline long __get_user_pages_locked(struct mm_struct *mm,
 			return -EAGAIN;
 		lock_dropped = true;
 		*locked = 1;
+	} else if (flags & FOLL_PIN) {
+		/*
+		 * The mmap lock must be held when calling this function. This
+		 * is true even for non-pin modes, but due to a shortcut in fork
+		 * not taking the lock for the new mm we cannot check this
+		 * comprehensively.
+		 */
+		mmap_assert_locked(mm);
 	}
 
 	if (flags & FOLL_PIN)
-- 
2.39.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux