Skip to content

Commit 375d315

Browse files
zongboxtorvalds
authored andcommitted
mm: add DEBUG_WX support
Patch series "Extract DEBUG_WX to shared use". Some architectures support DEBUG_WX function, it's verbatim from each others, so extract to mm/Kconfig.debug for shared use. PPC and ARM ports don't support generic page dumper yet, so we only refine x86 and arm64 port in this patch series. For RISC-V port, the DEBUG_WX support depends on other patches which be merged already: - RISC-V page table dumper - Support strict kernel memory permissions for security This patch (of 4): Some architectures support DEBUG_WX function, it's verbatim from each others. Extract to mm/Kconfig.debug for shared use. [[email protected]: reword text, per Will Deacon & Zong Li] Link: http://lkml.kernel.org/r/20200427194245.oxRJKj3fn%[email protected] [[email protected]: remove the specific name of arm64] Link: http://lkml.kernel.org/r/3a6a92ecedc54e1d0fc941398e63d504c2cd5611.1589178399.git.zong.li@sifive.com [[email protected]: add MMU dependency for DEBUG_WX] Link: http://lkml.kernel.org/r/4a674ac7863ff39ca91847b10e51209771f99416.1589178399.git.zong.li@sifive.com Suggested-by: Palmer Dabbelt <[email protected]> Signed-off-by: Zong Li <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/23980cd0f0e5d79e24a92169116407c75bcc650d.1587455584.git.zong.li@sifive.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4fb6eab commit 375d315

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

mm/Kconfig.debug

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,38 @@ config DEBUG_RODATA_TEST
118118
---help---
119119
This option enables a testcase for the setting rodata read-only.
120120

121+
config ARCH_HAS_DEBUG_WX
122+
bool
123+
124+
config DEBUG_WX
125+
bool "Warn on W+X mappings at boot"
126+
depends on ARCH_HAS_DEBUG_WX
127+
depends on MMU
128+
select PTDUMP_CORE
129+
help
130+
Generate a warning if any W+X mappings are found at boot.
131+
132+
This is useful for discovering cases where the kernel is leaving W+X
133+
mappings after applying NX, as such mappings are a security risk.
134+
135+
Look for a message in dmesg output like this:
136+
137+
<arch>/mm: Checked W+X mappings: passed, no W+X pages found.
138+
139+
or like this, if the check failed:
140+
141+
<arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.
142+
143+
Note that even if the check fails, your kernel is possibly
144+
still fine, as W+X mappings are not a security hole in
145+
themselves, what they do is that they make the exploitation
146+
of other unfixed kernel bugs easier.
147+
148+
There is no runtime or memory usage effect of this option
149+
once the kernel has booted up - it's a one time check.
150+
151+
If in doubt, say "Y".
152+
121153
config GENERIC_PTDUMP
122154
bool
123155

0 commit comments

Comments
 (0)