From: Stephen Smalley <sds@tycho.nsa.gov>
To: Ingo Molnar <mingo@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
keescook@chromium.org, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Denys Vlasenko <dvlasenk@redhat.com>,
Brian Gerst <brgerst@gmail.com>
Subject: Re: [PATCH v2] x86/mm: warn on W+x mappings
Date: Tue, 6 Oct 2015 11:37:57 -0400 [thread overview]
Message-ID: <5613EAD5.2070405@tycho.nsa.gov> (raw)
In-Reply-To: <20151006073205.GA11115@gmail.com>
On 10/06/2015 03:32 AM, Ingo Molnar wrote:
>
> * Stephen Smalley <sds@tycho.nsa.gov> wrote:
>
>> On 10/03/2015 07:27 AM, Ingo Molnar wrote:
>>>
>>> * Stephen Smalley <sds@tycho.nsa.gov> wrote:
>>>
>>>> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>>>> index 30564e2..f8b1573 100644
>>>> --- a/arch/x86/mm/init_64.c
>>>> +++ b/arch/x86/mm/init_64.c
>>>> @@ -1150,6 +1150,8 @@ void mark_rodata_ro(void)
>>>> free_init_pages("unused kernel",
>>>> (unsigned long) __va(__pa_symbol(rodata_end)),
>>>> (unsigned long) __va(__pa_symbol(_sdata)));
>>>> +
>>>> + debug_checkwx();
>>>
>>> Any reason to not do this on NX capable 32-bit kernels as well?
>>
>> Done in v3. However, I do see lots of W+X mappings there.
>
> Ha! That's a debug check plan gone very well! :)
>
>> [ 1.012796] WARNING: CPU: 1 PID: 1 at arch/x86/mm/dump_pagetables.c:225 note_page+0x65d/0x840()
>> [ 1.012803] x86/mm: Found insecure W+X mapping at address f4a00000/0xf4a00000
>
> What does this range correspond to on your kernel?
>From dmesg:
[ 0.000000] virtual kernel memory layout:
fixmap : 0xffa96000 - 0xfffff000 (5540 kB)
pkmap : 0xff800000 - 0xffa00000 (2048 kB)
vmalloc : 0xf7ffe000 - 0xff7fe000 ( 120 MB)
lowmem : 0xc0000000 - 0xf77fe000 ( 887 MB)
.init : 0xc0dde000 - 0xc0e9d000 ( 764 kB)
.data : 0xc0aa2ba0 - 0xc0ddca00 (3303 kB)
.text : 0xc0400000 - 0xc0aa2ba0 (6794 kB)
/sys/kernel/debug/kernel_page_tables seems to have many such mappings,
even before the reported one under Kernel Mapping, plus one in the vmalloc() area:
---[ Kernel Mapping ]---
0xc0000000-0xc009b000 620K RW GLB NX pte
0xc009b000-0xc009c000 4K ro GLB NX pte
0xc009c000-0xc009d000 4K ro GLB x pte
0xc009d000-0xc0200000 1420K RW GLB NX pte
0xc0200000-0xc0400000 2M RW PSE GLB NX pmd
0xc0400000-0xc0a00000 6M ro PSE GLB x pmd
0xc0a00000-0xc0aa3000 652K ro GLB x pte
0xc0aa3000-0xc0d2a000 2588K ro GLB NX pte
0xc0d2a000-0xc1000000 2904K RW GLB NX pte
0xc1000000-0xe7000000 608M RW PSE GLB NX pmd
0xe7000000-0xe7027000 156K RW GLB x pte
0xe7027000-0xe7028000 4K ro GLB x pte
0xe7028000-0xe709b000 460K RW GLB x pte
0xe709b000-0xe709c000 4K ro GLB x pte
0xe709c000-0xe70b8000 112K RW GLB x pte
0xe70b8000-0xe70b9000 4K ro GLB x pte
0xe70b9000-0xe7108000 316K RW GLB x pte
0xe7108000-0xe710a000 8K ro GLB x pte
0xe710a000-0xe7127000 116K RW GLB x pte
0xe7127000-0xe712a000 12K ro GLB x pte
<many additional ones elided>
0xf2c5c000-0xf2c5d000 4K ro GLB x pte
0xf2c5d000-0xf2e00000 1676K RW GLB x pte
0xf2e00000-0xf4a00000 28M RW PSE GLB NX pmd
0xf4a00000-0xf4b28000 1184K RW GLB x pte
0xf4b28000-0xf4c00000 864K RW GLB NX pte
0xf4c00000-0xf5200000 6M RW PSE GLB x pmd
0xf5200000-0xf525d000 372K RW GLB x pte
0xf525d000-0xf525e000 4K ro GLB x pte
0xf525e000-0xf525f000 4K RW GLB x pte
0xf525f000-0xf5260000 4K ro GLB x pte
0xf5260000-0xf526a000 40K RW GLB x pte
0xf6400000-0xf658c000 1584K RW GLB NX pte
0xf658c000-0xf6600000 464K RW GLB x pte
0xf6600000-0xf7600000 16M RW PSE GLB NX pmd
0xf7600000-0xf77fe000 2040K RW GLB NX pte
0xf77fe000-0xf7800000 8K pte
0xf7800000-0xf7e00000 6M pmd
0xf7e00000-0xf7ffe000 2040K pte
---[ vmalloc() Area ]---
0xf7ffe000-0xf7fff000 4K RW GLB NX pte
0xf7fff000-0xf8000000 4K pte
0xf8000000-0xf8002000 8K RW GLB NX pte
...
0xf86f3000-0xf8800000 1076K pte
0xf8800000-0xf8a00000 2M RW PWT PSE GLB x pmd
0xf8a00000-0xf8b00000 1M RW PWT GLB NX pte
$ grep -c 'RW.*x' kernel_page_tables
114
There was also an earlier W+X mapping originally that I squelched via pci=nobios.
next prev parent reply other threads:[~2015-10-06 15:40 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 19:29 [PATCH v2] x86/mm: warn on W+x mappings Stephen Smalley
2015-10-02 20:44 ` Kees Cook
2015-10-03 11:27 ` Ingo Molnar
2015-10-05 19:13 ` Stephen Smalley
2015-10-06 7:32 ` Ingo Molnar
2015-10-06 15:37 ` Stephen Smalley [this message]
2015-10-12 11:36 ` Borislav Petkov
[not found] ` <20151012113605.GB7384-fF5Pk5pvG8Y@public.gmane.org>
2015-10-12 12:41 ` Matt Fleming
2015-10-12 12:41 ` Matt Fleming
2015-10-12 12:49 ` Ingo Molnar
[not found] ` <20151012124936.GA6260-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-12 12:55 ` Matt Fleming
2015-10-12 12:55 ` Matt Fleming
[not found] ` <20151012125548.GE2579-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-12 14:17 ` Ingo Molnar
2015-10-12 14:17 ` Ingo Molnar
[not found] ` <20151012141754.GA6621-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-12 14:49 ` Matt Fleming
2015-10-12 14:49 ` Matt Fleming
[not found] ` <20151012144928.GF2579-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-12 15:34 ` Ard Biesheuvel
2015-10-12 15:34 ` Ard Biesheuvel
[not found] ` <CAKv+Gu95NoB5cPqZMeBLn7i0JWDDPKX63FuiMVD94HpbGhKrhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-12 15:50 ` Matt Fleming
2015-10-12 15:50 ` Matt Fleming
[not found] ` <20151012155028.GH2579-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-12 16:43 ` Ard Biesheuvel
2015-10-12 16:43 ` Ard Biesheuvel
2015-10-14 15:18 ` Ingo Molnar
2015-10-14 15:30 ` Andy Lutomirski
2015-10-14 15:35 ` Borislav Petkov
[not found] ` <20151014153522.GC8218-fF5Pk5pvG8Y@public.gmane.org>
2015-10-15 10:10 ` Matt Fleming
2015-10-15 10:10 ` Matt Fleming
[not found] ` <20151015101016.GB2975-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-15 10:33 ` Borislav Petkov
2015-10-15 10:33 ` Borislav Petkov
2015-10-16 1:45 ` Ricardo Neri
2015-10-16 1:45 ` Ricardo Neri
2015-10-14 21:02 ` Matt Fleming
2015-10-21 9:42 ` Ingo Molnar
[not found] ` <20151021094242.GA12155-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-21 12:49 ` Ingo Molnar
2015-10-21 12:49 ` Ingo Molnar
[not found] ` <20151021124924.GA19262-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-21 12:57 ` Ard Biesheuvel
2015-10-21 12:57 ` Ard Biesheuvel
2015-10-21 13:24 ` Borislav Petkov
[not found] ` <20151021132430.GD3575-fF5Pk5pvG8Y@public.gmane.org>
2015-10-21 13:28 ` Ard Biesheuvel
2015-10-21 13:28 ` Ard Biesheuvel
2015-10-21 14:36 ` Borislav Petkov
[not found] ` <20151021143651.GE3575-fF5Pk5pvG8Y@public.gmane.org>
2015-10-21 18:46 ` Andy Lutomirski
2015-10-21 18:46 ` Andy Lutomirski
[not found] ` <CALCETrWwHLnt6=MiyuQY48zEaOUMuFTg1oN3NDdEOxa6XYMgCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-21 20:45 ` Matt Fleming
2015-10-21 20:45 ` Matt Fleming
[not found] ` <20151021204522.GB20338-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-21 20:49 ` Andy Lutomirski
2015-10-21 20:49 ` Andy Lutomirski
2015-10-21 20:38 ` Matt Fleming
2015-10-21 20:38 ` Matt Fleming
2015-10-12 14:56 ` Josh Triplett
2015-10-14 15:19 ` Ingo Molnar
2015-10-14 16:47 ` Josh Triplett
2015-10-21 9:43 ` Ingo Molnar
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=5613EAD5.2070405@tycho.nsa.gov \
--to=sds@tycho.nsa.gov \
--cc=a.p.zijlstra@chello.nl \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@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.