Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4edcf0d authored by Dave Hansen's avatar Dave Hansen Committed by Ingo Molnar
Browse files

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: default avatarDave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: default avatarThomas 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: default avatarIngo Molnar <mingo@kernel.org>
parent cde70140
Loading
Loading
Loading
Loading
+2 −6
Original line number Original line Diff line number Diff line
@@ -2719,9 +2719,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
	/* Acquire the mm page semaphore. */
	/* Acquire the mm page semaphore. */
	down_read(&current->mm->mmap_sem);
	down_read(&current->mm->mmap_sem);


	err = get_user_pages(current,
	err = get_user_pages((unsigned long int)(oper.indata + prev_ix),
			     current->mm,
			     (unsigned long int)(oper.indata + prev_ix),
			     noinpages,
			     noinpages,
			     0,  /* read access only for in data */
			     0,  /* read access only for in data */
			     0, /* no force */
			     0, /* no force */
@@ -2736,9 +2734,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
	}
	}
	noinpages = err;
	noinpages = err;
	if (oper.do_cipher){
	if (oper.do_cipher){
		err = get_user_pages(current,
		err = get_user_pages((unsigned long int)oper.cipher_outdata,
				     current->mm,
				     (unsigned long int)oper.cipher_outdata,
				     nooutpages,
				     nooutpages,
				     1, /* write access for out data */
				     1, /* write access for out data */
				     0, /* no force */
				     0, /* no force */
+1 −2
Original line number Original line Diff line number Diff line
@@ -142,8 +142,7 @@ store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
	u64 virt_addr=simple_strtoull(buf, NULL, 16);
	u64 virt_addr=simple_strtoull(buf, NULL, 16);
	int ret;
	int ret;


        ret = get_user_pages(current, current->mm, virt_addr,
	ret = get_user_pages(virt_addr, 1, VM_READ, 0, NULL, NULL);
                        1, VM_READ, 0, NULL, NULL);
	if (ret<=0) {
	if (ret<=0) {
#ifdef ERR_INJ_DEBUG
#ifdef ERR_INJ_DEBUG
		printk("Virtual address %lx is not existing.\n",virt_addr);
		printk("Virtual address %lx is not existing.\n",virt_addr);
+1 −2
Original line number Original line Diff line number Diff line
@@ -286,8 +286,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
	start += nr << PAGE_SHIFT;
	start += nr << PAGE_SHIFT;
	pages += nr;
	pages += nr;


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


	/* Have to be a bit careful with return values */
	/* Have to be a bit careful with return values */
+1 −3
Original line number Original line Diff line number Diff line
@@ -210,7 +210,6 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
int get_user_pages_fast(unsigned long start, int nr_pages, int write,
int get_user_pages_fast(unsigned long start, int nr_pages, int write,
			struct page **pages)
			struct page **pages)
{
{
	struct mm_struct *mm = current->mm;
	int nr, ret;
	int nr, ret;


	might_sleep();
	might_sleep();
@@ -222,8 +221,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
	/* Try to get the remaining pages with get_user_pages */
	/* Try to get the remaining pages with get_user_pages */
	start += nr << PAGE_SHIFT;
	start += nr << PAGE_SHIFT;
	pages += nr;
	pages += nr;
	ret = get_user_pages_unlocked(current, mm, start,
	ret = get_user_pages_unlocked(start, nr_pages - nr, write, 0, pages);
			     nr_pages - nr, write, 0, pages);
	/* Have to be a bit careful with return values */
	/* Have to be a bit careful with return values */
	if (nr > 0)
	if (nr > 0)
		ret = (ret < 0) ? nr : ret + nr;
		ret = (ret < 0) ? nr : ret + nr;
+1 −1
Original line number Original line Diff line number Diff line
@@ -257,7 +257,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
		start += nr << PAGE_SHIFT;
		start += nr << PAGE_SHIFT;
		pages += nr;
		pages += nr;


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


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