All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Menzel <pmenzel@molgen.mpg.de>
To: "Thomas Gleixner" <tglx@linutronix.de>, "Jörg Rödel" <joro@8bytes.org>
Cc: Borislav Petkov <bp@alien8.de>,
	linux-mm@kvack.org, x86@kernel.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: x86/mm: Found insecure W+X mapping at address (ptrval)/0xc00a0000
Date: Fri, 5 Oct 2018 11:39:13 +0200	[thread overview]
Message-ID: <74dededa-3754-058b-2291-a349b9f3673e@molgen.mpg.de> (raw)
In-Reply-To: <alpine.DEB.2.21.1810051124320.3960@nanos.tec.linutronix.de>

[-- Attachment #1: Type: text/plain, Size: 2595 bytes --]

Dear Thomas,


On 10/05/18 11:27, Thomas Gleixner wrote:
> On Thu, 4 Oct 2018, Joerg Roedel wrote:
> 
>> On Wed, Oct 03, 2018 at 11:22:55PM +0200, Borislav Petkov wrote:
>>> On Fri, Sep 28, 2018 at 04:55:19PM +0200, Thomas Gleixner wrote:
>>>> Sorry for the delay and thanks for the data. A quick diff did not reveal
>>>> anything obvious. I'll have a closer look and we probably need more (other)
>>>> information to nail that down.
>>
>> I also triggered this when working in the PTI-x32 code. It always
>> happens on a 32-bit PAE kernel for me.
>>
>> Tracking it down I ended up in (iirc) arch/x86/mm/pageattr.c
>> 	function static_protections():
>>
>> 		/*
>> 		 * The BIOS area between 640k and 1Mb needs to be executable for
>> 		 * PCI BIOS based config access (CONFIG_PCI_GOBIOS) support.
>> 		 */
>> 	#ifdef CONFIG_PCI_BIOS
>> 		if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
>> 			pgprot_val(forbidden) |= _PAGE_NX;
>> 	#endif
>>
>> I think that is the reason we are seeing this in that configuration.
> 
> Uurgh. Yes.
> 
> If pcibios is enabled and used, need to look at the gory details of that
> first, then the W+X check has to exclude that region. We can't do much
> about that.

That would also explain, why it only happens with the SeaBIOS payload,
which sets up legacy BIOS calls. Using GRUB directly as payload, no BIOS
calls are set up.

Reading the Kconfig description of the PCI access mode, the BIOS should
only be used last.

> choice  
>         prompt "PCI access mode"
>         depends on X86_32 && PCI
>         default PCI_GOANY
>         ---help---
>           On PCI systems, the BIOS can be used to detect the PCI devices and
>           determine their configuration. However, some old PCI motherboards
>           have BIOS bugs and may crash if this is done. Also, some embedded
>           PCI-based systems don't have any BIOS at all. Linux can also try to
>           detect the PCI hardware directly without using the BIOS.
> 
>           With this option, you can specify how Linux should detect the
>           PCI devices. If you choose "BIOS", the BIOS will be used,
>           if you choose "Direct", the BIOS won't be used, and if you
>           choose "MMConfig", then PCI Express MMCONFIG will be used.
>           If you choose "Any", the kernel will try MMCONFIG, then the
>           direct access method and falls back to the BIOS if that doesn't
>           work. If unsure, go with the default, which is "Any".


Kind regards,

Paul


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5174 bytes --]

  reply	other threads:[~2018-10-05  9:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19  6:55 x86/mm: Found insecure W+X mapping at address (ptrval)/0xc00a0000 Paul Menzel
2018-09-19  8:09 ` Thomas Gleixner
2018-09-20  7:07   ` Paul Menzel
2018-09-20 22:51     ` Thomas Gleixner
2018-09-24 21:47       ` Paul Menzel
2018-09-28 14:55         ` Thomas Gleixner
2018-10-03 21:22           ` Borislav Petkov
2018-10-04  3:11             ` Paul Menzel
2018-10-04  7:48               ` Borislav Petkov
2018-10-04  8:03             ` Joerg Roedel
2018-10-04  8:14               ` Borislav Petkov
2018-10-04  8:40                 ` Paul Menzel
2018-10-04  8:49                   ` Borislav Petkov
2018-10-04  8:59                     ` Paul Menzel
2018-10-04 10:54                       ` Borislav Petkov
2018-10-04 11:00                         ` Paul Menzel
2018-10-04 11:12                           ` Borislav Petkov
2018-10-04  8:43                 ` Joerg Roedel
2018-10-04  8:48                   ` Borislav Petkov
2018-10-05  9:27               ` Thomas Gleixner
2018-10-05  9:39                 ` Paul Menzel [this message]
2018-10-08 19:37                   ` Thomas Gleixner
2018-10-08 20:08                     ` Bjorn Helgaas

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=74dededa-3754-058b-2291-a349b9f3673e@molgen.mpg.de \
    --to=pmenzel@molgen.mpg.de \
    --cc=bp@alien8.de \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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.