Skip to content

Commit d4edcf0

Browse files
hansendcIngo Molnar
authored andcommitted
mm/gup: Switch all callers of get_user_pages() to not pass tsk/mm
We will soon modify the vanilla get_user_pages() so it can no longer be used on mm/tasks other than 'current/current->mm', which is by far the most common way it is called. For now, we allow the old-style calls, but warn when they are used. (implemented in previous patch) This patch switches all callers of: get_user_pages() get_user_pages_unlocked() get_user_pages_locked() to stop passing tsk/mm so they will no longer see the warnings. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave@sr71.net> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: jack@suse.cz Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20160212210156.113E9407@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent cde7014 commit d4edcf0

File tree

29 files changed

+44
-64
lines changed

29 files changed

+44
-64
lines changed

arch/cris/arch-v32/drivers/cryptocop.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,9 +2719,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
27192719
/* Acquire the mm page semaphore. */
27202720
down_read(&current->mm->mmap_sem);
27212721

2722-
err = get_user_pages(current,
2723-
current->mm,
2724-
(unsigned long int)(oper.indata + prev_ix),
2722+
err = get_user_pages((unsigned long int)(oper.indata + prev_ix),
27252723
noinpages,
27262724
0, /* read access only for in data */
27272725
0, /* no force */
@@ -2736,9 +2734,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
27362734
}
27372735
noinpages = err;
27382736
if (oper.do_cipher){
2739-
err = get_user_pages(current,
2740-
current->mm,
2741-
(unsigned long int)oper.cipher_outdata,
2737+
err = get_user_pages((unsigned long int)oper.cipher_outdata,
27422738
nooutpages,
27432739
1, /* write access for out data */
27442740
0, /* no force */

arch/ia64/kernel/err_inject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
142142
u64 virt_addr=simple_strtoull(buf, NULL, 16);
143143
int ret;
144144

145-
ret = get_user_pages(current, current->mm, virt_addr,
146-
1, VM_READ, 0, NULL, NULL);
145+
ret = get_user_pages(virt_addr, 1, VM_READ, 0, NULL, NULL);
147146
if (ret<=0) {
148147
#ifdef ERR_INJ_DEBUG
149148
printk("Virtual address %lx is not existing.\n",virt_addr);

arch/mips/mm/gup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
286286
start += nr << PAGE_SHIFT;
287287
pages += nr;
288288

289-
ret = get_user_pages_unlocked(current, mm, start,
290-
(end - start) >> PAGE_SHIFT,
289+
ret = get_user_pages_unlocked(start, (end - start) >> PAGE_SHIFT,
291290
write, 0, pages);
292291

293292
/* Have to be a bit careful with return values */

arch/s390/mm/gup.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
210210
int get_user_pages_fast(unsigned long start, int nr_pages, int write,
211211
struct page **pages)
212212
{
213-
struct mm_struct *mm = current->mm;
214213
int nr, ret;
215214

216215
might_sleep();
@@ -222,8 +221,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
222221
/* Try to get the remaining pages with get_user_pages */
223222
start += nr << PAGE_SHIFT;
224223
pages += nr;
225-
ret = get_user_pages_unlocked(current, mm, start,
226-
nr_pages - nr, write, 0, pages);
224+
ret = get_user_pages_unlocked(start, nr_pages - nr, write, 0, pages);
227225
/* Have to be a bit careful with return values */
228226
if (nr > 0)
229227
ret = (ret < 0) ? nr : ret + nr;

arch/sh/mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
257257
start += nr << PAGE_SHIFT;
258258
pages += nr;
259259

260-
ret = get_user_pages_unlocked(current, mm, start,
260+
ret = get_user_pages_unlocked(start,
261261
(end - start) >> PAGE_SHIFT, write, 0, pages);
262262

263263
/* Have to be a bit careful with return values */

arch/sparc/mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
237237
start += nr << PAGE_SHIFT;
238238
pages += nr;
239239

240-
ret = get_user_pages_unlocked(current, mm, start,
240+
ret = get_user_pages_unlocked(start,
241241
(end - start) >> PAGE_SHIFT, write, 0, pages);
242242

243243
/* Have to be a bit careful with return values */

arch/x86/mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
422422
start += nr << PAGE_SHIFT;
423423
pages += nr;
424424

425-
ret = get_user_pages_unlocked(current, mm, start,
425+
ret = get_user_pages_unlocked(start,
426426
(end - start) >> PAGE_SHIFT,
427427
write, 0, pages);
428428

arch/x86/mm/mpx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ static int mpx_resolve_fault(long __user *addr, int write)
546546
int nr_pages = 1;
547547
int force = 0;
548548

549-
gup_ret = get_user_pages(current, current->mm, (unsigned long)addr,
550-
nr_pages, write, force, NULL, NULL);
549+
gup_ret = get_user_pages((unsigned long)addr, nr_pages, write,
550+
force, NULL, NULL);
551551
/*
552552
* get_user_pages() returns number of pages gotten.
553553
* 0 means we failed to fault in and get anything,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
518518
uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE;
519519
struct page **pages = ttm->pages + pinned;
520520

521-
r = get_user_pages(current, current->mm, userptr, num_pages,
522-
write, 0, pages, NULL);
521+
r = get_user_pages(userptr, num_pages, write, 0, pages, NULL);
523522
if (r < 0)
524523
goto release_pages;
525524

drivers/gpu/drm/radeon/radeon_ttm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,7 @@ static int radeon_ttm_tt_pin_userptr(struct ttm_tt *ttm)
554554
uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE;
555555
struct page **pages = ttm->pages + pinned;
556556

557-
r = get_user_pages(current, current->mm, userptr, num_pages,
558-
write, 0, pages, NULL);
557+
r = get_user_pages(userptr, num_pages, write, 0, pages, NULL);
559558
if (r < 0)
560559
goto release_pages;
561560

0 commit comments

Comments
 (0)