Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1233223

Re: rwx mapping between ex_table and rodata

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: rwx mapping between ex_table and rodata
Date 2015-09-26 18:50 +0200
Message-ID <qd0PD-5Bg-17@gated-at.bofh.it> (permalink)
References <qclt7-5sk-5@gated-at.bofh.it> <qclCO-5zE-9@gated-at.bofh.it> <qcnbz-7Zv-11@gated-at.bofh.it> <qcvCa-32z-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Sep 25, 2015 at 12:22 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Kees Cook <keescook@chromium.org> wrote:
>
>> On Thu, Sep 24, 2015 at 1:26 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>> > Hi,
>> >
>> > With the attached config and 4.3-rc2 on x86_64, I see the following in /sys/kernel/debug/kernel_page_tables:
>> > ...
>> > ---[ High Kernel Mapping ]---
>> > 0xffffffff80000000-0xffffffff81000000          16M                               pmd
>> > 0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
>> > 0xffffffff81600000-0xffffffff81775000        1492K     ro                 GLB x  pte
>> > 0xffffffff81775000-0xffffffff81800000         556K     RW                 GLB x  pte
>> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> > 0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
>> > 0xffffffff81a00000-0xffffffff81b43000        1292K     ro                 GLB NX pte
>> > 0xffffffff81b43000-0xffffffff82000000        4852K     RW                 GLB NX pte
>> > 0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
>> > 0xffffffff82200000-0xffffffffa0000000         478M                               pmd
>> > ...
>> >
>> > This region seems to be between the end of ex_table and the start of rodata,
>> > $ objdump -x vmlinux | sort
>> > ...
>> > ffffffff817728b0 g       __ex_table     0000000000000000 __start___ex_table
>> > ffffffff817728b0 l    d  __ex_table     0000000000000000 __ex_table
>> > ffffffff81774998 g       __ex_table     0000000000000000 __stop___ex_table
>> > ffffffff81800000 g       .rodata        0000000000000000 __start_rodata
>> > ffffffff81800000 l    d  .rodata        0000000000000000 .rodata
>> > ...
>> >
>> > $ readelf -a vmlinux
>> > ...
>> > Section Headers:
>> >   [Nr] Name              Type             Address           Offset
>> >        Size              EntSize          Flags  Link  Info  Align
>> > ...
>> >   [ 3] __ex_table        PROGBITS         ffffffff817728b0  009728b0
>> >        00000000000020e8  0000000000000000   A       0     0     8
>> >   [ 4] .rodata           PROGBITS         ffffffff81800000  00a00000
>> >        00000000002eefd2  0000000000000000   A       0     0     64
>> > ...
>> >
>> > I see a similar rwx mapping with the stock Fedora kernels (e.g. 4.1.6), so it isn't new to 4.3.
>>
>> To me it looks like another alignment/padding issue like got fixed
>> before. The space between __ex_table and rodata is (seems?) unused, so
>> the default page table permissions end up being W+X. Can we fix the
>> default to be NX instead? It'll make these bugs stay gone.
>
> Yeah. Wanna send a patch for that?

I haven't found where that is actually happening. :( If anyone has
pointers, I can dig a bit more.

-Kees

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: rwx mapping between ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-09-25 00:30 +0200
  Re: rwx mapping between ex_table and rodata Ingo Molnar <mingo@kernel.org> - 2015-09-25 09:30 +0200
  Re: rwx mapping between ex_table and rodata Ingo Molnar <mingo@kernel.org> - 2015-09-25 09:30 +0200
    Re: rwx mapping between ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-09-26 18:50 +0200
    Re: rwx mapping between ex_table and rodata "H. Peter Anvin" <hpa@zytor.com> - 2015-09-28 23:20 +0200
      Re: rwx mapping between ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-09-29 00:10 +0200
        Re: rwx mapping between ex_table and rodata "H. Peter Anvin" <hpa@zytor.com> - 2015-09-29 00:30 +0200
  Re: rwx mapping between ex_table and rodata Stephen Smalley <sds@tycho.nsa.gov> - 2015-09-28 16:20 +0200
    Re: rwx mapping between ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-09-28 20:30 +0200
      Re: rwx mapping between ex_table and rodata Ingo Molnar <mingo@kernel.org> - 2015-10-01 09:20 +0200
      Re: rwx mapping between ex_table and rodata Thomas Gleixner <tglx@linutronix.de> - 2015-10-01 11:10 +0200
        Re: rwx mapping between ex_table and rodata Ingo Molnar <mingo@kernel.org> - 2015-10-01 11:20 +0200
          Re: rwx mapping between ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-10-01 19:50 +0200
            Re: rwx mapping between ex_table and rodata Ingo Molnar <mingo@kernel.org> - 2015-10-02 09:20 +0200

csiph-web