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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.11.1511271054350.3572@nanos>
Date:	Fri, 27 Nov 2015 11:12:58 +0100 (CET)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Dave Hansen <dave@...1.net>
cc:	linux-kernel@...r.kernel.org, x86@...nel.org,
	dave.hansen@...ux.intel.com
Subject: Re: [PATCH 19/37] x86, mm: simplify get_user_pages() PTE bit
 handling

On Mon, 16 Nov 2015, Dave Hansen wrote:
> +static inline int pte_allows_gup(pte_t pte, int write)
> +{
> +	/*
> +	 * 'entry_flags' can come from a pte, pmd or pud.  Make
> +	 * sure to only check flags here that are valid *and* the
> +	 * same value on all 3 types.  (PAT is currently the only
> +	 * one where that is true and is not checked here).

I have a hard time to understand that comment.

       /*
        * 'entry_flags' can come from a pte, pmd or pud. We only check
	* _PAGE_PRESENT, _PAGE_USER and _PAGE_RW here, which are the
	* same for all types.
        */

Is that what you wanted to say?

> +	 */
> +	if (!(pte_flags(pte) & (_PAGE_PRESENT|_PAGE_USER)))
> +		return 0;
> +	if (write && !(pte_write(pte)))
> +		return 0;
> +	return 1;
> +}
> +
> +static inline int pmd_allows_gup(pmd_t pmd, int write)
> +{
> +	return pte_allows_gup(*(pte_t *)&pmd, write);
> +}
> +
> +static inline int pud_allows_gup(pud_t pud, int write)
> +{
> +	return pte_allows_gup(*(pte_t *)&pud, write);
> +}
> +

>  static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,
>  		unsigned long end, int write, struct page **pages, int *nr)
>  {
> -	unsigned long mask;
>  	struct page *head, *page;
>  	int refs;
>  
> -	mask = _PAGE_PRESENT|_PAGE_USER;
> -	if (write)
> -		mask |= _PAGE_RW;
> -	if ((pmd_flags(pmd) & mask) != mask)
> +	if (!pmd_allows_gup(pmd, write))

Why do you need that extra indirection here of rereading the pmd?
You have the pmd already.

Thanks,

	tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ