All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>, x86 team <x86@kernel.org>
Subject: Re: [PATCH] x86/mm: Prevent bogus warnings with "noexec=off"
Date: Tue, 16 Apr 2019 00:57:06 +0200	[thread overview]
Message-ID: <20066a63-4d7e-c0e9-23fa-4653d1dae8df@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1904151037530.1729@nanos.tec.linutronix.de>

On 4/15/19 10:46 AM, Thomas Gleixner wrote:

> Xose reported warnings when NX is disabled on the kernel command line.

Thank you for doing the dirty work.

> 
> __early_set_fixmap() triggers:
> 
>   attempted to set unsupported pgprot:    8000000000000163
>   	       	   	       bits:      8000000000000000
> 			       supported: 7fffffffffffffff
> 
>   WARNING: CPU: 0 PID: 0 at arch/x86/include/asm/pgtable.h:537
>   	   	       	    __early_set_fixmap+0xa2/0xff
> 
> because it uses __default_kernel_pte_mask to mask out unsupported bits.
> 
> Use __supported_pte_mask instead.
> 
> Disabling NX on the command line also triggers the NX warning in the page
> table mapping check:
> 
>   WARNING: CPU: 1 PID: 1 at arch/x86/mm/dump_pagetables.c:262 note_page+0x2ae/0x650
>   ....
> 
> Make the warning depend on NX set in __supported_pte_mask.
> 
> Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>

And
Tested-by: Xose Vazquez Perez <xose.vazquez@gmail.com>

> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/x86/mm/dump_pagetables.c |    3 ++-
>  arch/x86/mm/ioremap.c         |    2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> --- a/arch/x86/mm/dump_pagetables.c
> +++ b/arch/x86/mm/dump_pagetables.c
> @@ -259,7 +259,8 @@ static void note_wx(struct pg_state *st)
>  #endif
>  	/* Account the WX pages */
>  	st->wx_pages += npages;
> -	WARN_ONCE(1, "x86/mm: Found insecure W+X mapping at address %pS\n",
> +	WARN_ONCE(__supported_pte_mask & _PAGE_NX,
> +		  "x86/mm: Found insecure W+X mapping at address %pS\n",
>  		  (void *)st->start_address);
>  }
>  
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -825,7 +825,7 @@ void __init __early_set_fixmap(enum fixe
>  	pte = early_ioremap_pte(addr);
>  
>  	/* Sanitize 'prot' against any unsupported bits: */
> -	pgprot_val(flags) &= __default_kernel_pte_mask;
> +	pgprot_val(flags) &= __supported_pte_mask;
>  
>  	if (pgprot_val(flags))
>  		set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));
> 


  reply	other threads:[~2019-04-15 22:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-13 20:53 bug disabling NX (noexec=off) Xose Vazquez Perez
2019-04-14  9:59 ` Thomas Gleixner
2019-04-14 21:26   ` Xose Vazquez Perez
2019-04-15  8:46     ` [PATCH] x86/mm: Prevent bogus warnings with "noexec=off" Thomas Gleixner
2019-04-15 22:57       ` Xose Vazquez Perez [this message]
2019-04-16  7:46       ` [tip:x86/urgent] " tip-bot for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20066a63-4d7e-c0e9-23fa-4653d1dae8df@gmail.com \
    --to=xose.vazquez@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.