• Stephen Smalley's avatar
    x86/mm: Set NX on gap between __ex_table and rodata · 29d61448
    Stephen Smalley authored
    commit ab76f7b4 upstream.
    
    Unused space between the end of __ex_table and the start of
    rodata can be left W+x in the kernel page tables.  Extend the
    setting of the NX bit to cover this gap by starting from
    text_end rather than rodata_start.
    
      Before:
      ---[ High Kernel Mapping ]---
      0xffffffff80000000-0xffffffff81000000          16M                               pmd
      0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
      0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
      0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB x  pte
      0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
      0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
      0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
      0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
      0xffffffff82200000-0xffffffffa0000000         478M                               pmd
    
      After:
      ---[ High Kernel Mapping ]---
      0xffffffff80000000-0xffffffff81000000          16M                               pmd
      0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
      0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
      0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB NX pte
      0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
      0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
      0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
      0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
      0xffffffff82200000-0xffffffffa0000000         478M                               pmd
    Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
    Acked-by: default avatarKees Cook <keescook@chromium.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Link: http://lkml.kernel.org/r/1443704662-3138-1-git-send-email-sds@tycho.nsa.govSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
    29d61448
init_64.c 33.3 KB