lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 21 May 2020 18:04:43 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     Andrew Morton <akpm@...ux-foundation.org>, <jgg@...pe.ca>
CC:     <Liam.Howlett@...cle.com>, <daniel.m.jordan@...cle.com>,
        <dave@...olabs.net>, <hughd@...gle.com>, <jglisse@...hat.com>,
        <jhubbard@...dia.com>, <ldufour@...ux.ibm.com>,
        <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
        <peterz@...radead.org>, <rientjes@...gle.com>, <vbabka@...e.cz>,
        <walken@...gle.com>, <willy@...radead.org>, <yinghan@...gle.com>
Subject: [PATCH] mm/gup: might_lock_read(mmap_sem) in get_user_pages_fast()

Instead of scattering these assertions across the drivers,
do this assertion inside the core of get_user_pages_fast*()
functions. That also includes pin_user_pages_fast*()
routines.

Add a might_lock_read(mmap_sem) call to internal_get_user_pages_fast().

Suggested-by: Matthew Wilcox <willy@...radead.org>
Cc: Michel Lespinasse <walken@...gle.com>
Cc: Jason Gunthorpe <jgg@...pe.ca>
Signed-off-by: John Hubbard <jhubbard@...dia.com>
---

Hi Andrew,

This applies on top of [1], which in turn applies to
today's (20200521) linux-next.

As noted in the discussion [2], this will need changing from
mmap_sem to mmap_lock, after Michel Lespinasse's patchset
arrives.

[1]
https://lore.kernel.org/r/20200521233841.1279742-1-jhubbard@nvidia.com

[2] https://lore.kernel.org/linux-mm/20200520124817.GG31189@ziepe.ca/

thanks,
John Hubbard
NVIDIA

 mm/gup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index ada6aa79576dc..3462c076e8ecf 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2728,6 +2728,9 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages,
 				       FOLL_FAST_ONLY)))
 		return -EINVAL;
 
+	if (!(gup_flags & FOLL_FAST_ONLY))
+		might_lock_read(&current->mm->mmap_sem);
+
 	start = untagged_addr(start) & PAGE_MASK;
 	addr = start;
 	len = (unsigned long) nr_pages << PAGE_SHIFT;
-- 
2.26.2

Powered by blists - more mailing lists