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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 13 Jan 2016 20:00:49 +0100
From:	Vlastimil Babka <vbabka@...e.cz>
To:	Dave Hansen <dave@...1.net>, linux-kernel@...r.kernel.org
Cc:	linux-mm@...ck.org, x86@...nel.org, dave.hansen@...ux.intel.com,
	akpm@...ux-foundation.org, kirill.shutemov@...ux.intel.com,
	aarcange@...hat.com, n-horiguchi@...jp.nec.com
Subject: Re: [PATCH 01/31] mm, gup: introduce concept of "foreign"
 get_user_pages()

On 01/07/2016 01:01 AM, Dave Hansen wrote:
> From: Dave Hansen <dave.hansen@...ux.intel.com>
> 
> For protection keys, we need to understand whether protections
> should be enforced in software or not.  In general, we enforce
> protections when working on our own task, but not when on others.
> We call these "current" and "foreign" operations.
> 
> This introduces two new get_user_pages() variants:
> 
> 	get_current_user_pages()
> 	get_foreign_user_pages()
> 
> get_current_user_pages() is a drop-in replacement for when
> get_user_pages() was called with (current, current->mm, ...) as
> arguments.  Using it makes a few of the call sites look a bit
> nicer.
> 
> get_foreign_user_pages() is a replacement for when
> get_user_pages() is called on non-current tsk/mm.
> 
> We leave a stub get_user_pages() around with a __deprecated
> warning.

Hm when replying to previous version I assumed this is because there are many
get_user_pages() callers remaining. But now I see there are just 3 drivers not
converted by this patch? In that case I would favor to convert get_user_pages()
to become what is now get_current_user_pages(). This would be much more
consistent IMHO. We don't need to cater to out-of-tree modules?

Sorry, I should have looked thoroughly on the previous reply, not just assume.

> This also effectively turns get_user_pages_unlocked() in to
> get_user_pages_unlocked_current() since it no longer gets a
> tsk/mm passed in.  I thought that would be too long of a name if
> we added "_current" on there.  BTW, if someone wants the
> get_user_pages_unlocked() behavior with a non-current tsk/mm,
> they just have to use __get_user_pages_unlocked() directly.
> 
> Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Cc: Andrea Arcangeli <aarcange@...hat.com>
> Cc: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
> Cc: vbabka@...e.cz
> ---

Also (but moot if you accept my suggestion):

> diff -puN mm/nommu.c~get_current_user_pages mm/nommu.c
> --- a/mm/nommu.c~get_current_user_pages	2016-01-06 15:50:02.230003599 -0800
> +++ b/mm/nommu.c	2016-01-06 15:50:02.259004906 -0800
> @@ -182,7 +182,7 @@ finish_or_fault:
>   *   slab page or a secondary page from a compound page
>   * - don't permit access to VMAs that don't support it, such as I/O mappings
>   */
> -long get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
> +long get_foreign_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>  		    unsigned long start, unsigned long nr_pages,
>  		    int write, int force, struct page **pages,
>  		    struct vm_area_struct **vmas)
> @@ -199,35 +199,41 @@ long get_user_pages(struct task_struct *
>  }
>  EXPORT_SYMBOL(get_user_pages);

I think you need to change the export here as you did in gup.c

>  
> -long get_user_pages_locked(struct task_struct *tsk, struct mm_struct *mm,
> -			   unsigned long start, unsigned long nr_pages,
> +long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
>  			   int write, int force, struct page **pages,
>  			   int *locked)
>  {
> -	return get_user_pages(tsk, mm, start, nr_pages, write, force,
> -			      pages, NULL);
> +	return get_user_pages(current, current->mm, start, nr_pages, write,
> +			      force, pages, NULL);

Why not use the _current variant here?

>  }
>  EXPORT_SYMBOL(get_user_pages_locked);
>  
> -long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
> -			       unsigned long start, unsigned long nr_pages,
> +long get_current_user_pages(unsigned long start, unsigned long nr_pages,
> +		    int write, int force, struct page **pages,
> +		    struct vm_area_struct **vmas)
> +{
> +	return get_foreign_user_pages(current, current->mm, start, nr_pages,
> +				      write, force, pages, vmas);
> +}
> +EXPORT_SYMBOL(get_current_user_pages);
> +
> +long __get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>  			       int write, int force, struct page **pages,
>  			       unsigned int gup_flags)
>  {
>  	long ret;
> -	down_read(&mm->mmap_sem);
> -	ret = get_user_pages(tsk, mm, start, nr_pages, write, force,
> -			     pages, NULL);
> -	up_read(&mm->mmap_sem);
> +	down_read(&current->mm->mmap_sem);
> +	ret = get_current_user_pages(start, nr_pages, write, force,
> +				     pages, NULL);
> +	up_read(&current->mm->mmap_sem);
>  	return ret;
>  }
>  EXPORT_SYMBOL(__get_user_pages_unlocked);
>  
> -long get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
> -			     unsigned long start, unsigned long nr_pages,
> +long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>  			     int write, int force, struct page **pages)
>  {
> -	return __get_user_pages_unlocked(tsk, mm, start, nr_pages, write,
> +	return __get_user_pages_unlocked(start, nr_pages, write,
>  					 force, pages, 0);
>  }
>  EXPORT_SYMBOL(get_user_pages_unlocked);
> diff -puN mm/process_vm_access.c~get_current_user_pages mm/process_vm_access.c

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ