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]
Message-ID: <CAGXu5jKdaq=xHvvQ6GazhnWsPu4R16Gbo1OrPatKxVRf4ZYuPA@mail.gmail.com>
Date:   Mon, 8 Oct 2018 17:00:51 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>, X86 ML <x86@...nel.org>,
        Paul Menzel <pmenzel@...gen.mpg.de>,
        Joerg Roedel <joro@...tes.org>,
        Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH] x86/mm: Do not warn about PCI BIOS W+X mappings

On Mon, Oct 8, 2018 at 12:53 PM, Thomas Gleixner <tglx@...utronix.de> wrote:
> PCI BIOS requires the BIOS area 0x0A0000-0x0FFFFFF to be mapped W+X for
> various legacy reasons. When CONFIG_DEBUG_WX is enabled, this triggers the
> WX warning, but this is misleading because the mapping is required and is
> not a result of an accidental oversight.
>
> Prevent the full warning when PCI BIOS is enabled and the detected WX
> mapping is in the BIOS area. Just emit a pr_warn() which denotes the
> fact. This is partially duplicating the info which the PCI BIOS code emits
> when it maps the area as executable, but that info is not in the context of
> the WX checking output.
>
> Reported-by: Paul Menzel <pmenzel@...gen.mpg.de>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Joerg Roedel <joro@...tes.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Bjorn Helgaas <bhelgaas@...gle.com>
> ---
>  arch/x86/mm/dump_pagetables.c |   35 +++++++++++++++++++++++++++--------
>  1 file changed, 27 insertions(+), 8 deletions(-)
>
> --- a/arch/x86/mm/dump_pagetables.c
> +++ b/arch/x86/mm/dump_pagetables.c
> @@ -19,7 +19,9 @@
>  #include <linux/sched.h>
>  #include <linux/seq_file.h>
>  #include <linux/highmem.h>
> +#include <linux/pci.h>
>
> +#include <asm/e820/types.h>
>  #include <asm/pgtable.h>
>
>  /*
> @@ -241,6 +243,29 @@ static unsigned long normalize_addr(unsi
>         return (signed long)(u << shift) >> shift;
>  }
>
> +static void note_wx(struct pg_state *st)
> +{
> +       unsigned long npages;
> +
> +       npages = (st->current_address - st->start_address) / PAGE_SIZE;
> +
> +#ifdef CONFIG_PCI_BIOS
> +       /*
> +        * If PCI BIOS is enabled, the PCI BIOS area is forced to WX.
> +        * Inform about it, but avoid the warning.
> +        */
> +       if (pcibios_enabled && st->start_address >= PAGE_OFFSET + BIOS_BEGIN &&
> +           st->current_address <= PAGE_OFFSET + BIOS_END) {
> +               pr_warn_once("x86/mm: PCI BIOS W+X mapping %lu pages\n", npages);
> +               return;
> +       }
> +#endif
> +       /* Account the WX pages */
> +       st->wx_pages += npages;
> +       WARN_ONCE(1, "x86/mm: Found insecure W+X mapping at address %p/%pS\n",
> +                 (void *)st->start_address, (void *)st->start_address);

Probably we should just drop the "%p/" part. %pS should give us
everything we need and %p will be meaningless normally.

Otherwise, yes, this look good.

-Kees

-- 
Kees Cook
Pixel Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ