Commit aa9f10d5 authored by Marco Elver's avatar Marco Elver Committed by Kees Cook

hardening: Move BUG_ON_DATA_CORRUPTION to hardening options

BUG_ON_DATA_CORRUPTION is turning detected corruptions of list data
structures from WARNings into BUGs. This can be useful to stop further
corruptions or even exploitation attempts.

However, the option has less to do with debugging than with hardening.
With the introduction of LIST_HARDENED, it makes more sense to move it
to the hardening options, where it selects LIST_HARDENED instead.

Without this change, combining BUG_ON_DATA_CORRUPTION with LIST_HARDENED
alone wouldn't be possible, because DEBUG_LIST would always be selected
by BUG_ON_DATA_CORRUPTION.
Signed-off-by: default avatarMarco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20230811151847.1594958-4-elver@google.comSigned-off-by: default avatarKees Cook <keescook@chromium.org>
parent aebc7b0d
...@@ -1673,7 +1673,7 @@ menu "Debug kernel data structures" ...@@ -1673,7 +1673,7 @@ menu "Debug kernel data structures"
config DEBUG_LIST config DEBUG_LIST
bool "Debug linked list manipulation" bool "Debug linked list manipulation"
depends on DEBUG_KERNEL || BUG_ON_DATA_CORRUPTION depends on DEBUG_KERNEL
select LIST_HARDENED select LIST_HARDENED
help help
Enable this to turn on extended checks in the linked-list walking Enable this to turn on extended checks in the linked-list walking
...@@ -1715,16 +1715,6 @@ config DEBUG_NOTIFIERS ...@@ -1715,16 +1715,6 @@ config DEBUG_NOTIFIERS
This is a relatively cheap check but if you care about maximum This is a relatively cheap check but if you care about maximum
performance, say N. performance, say N.
config BUG_ON_DATA_CORRUPTION
bool "Trigger a BUG when data corruption is detected"
select DEBUG_LIST
help
Select this option if the kernel should BUG when it encounters
data corruption in kernel memory structures when they get checked
for validity.
If unsure, say N.
config DEBUG_MAPLE_TREE config DEBUG_MAPLE_TREE
bool "Debug maple trees" bool "Debug maple trees"
depends on DEBUG_KERNEL depends on DEBUG_KERNEL
......
...@@ -290,6 +290,16 @@ config LIST_HARDENED ...@@ -290,6 +290,16 @@ config LIST_HARDENED
If unsure, say N. If unsure, say N.
config BUG_ON_DATA_CORRUPTION
bool "Trigger a BUG when data corruption is detected"
select LIST_HARDENED
help
Select this option if the kernel should BUG when it encounters
data corruption in kernel memory structures when they get checked
for validity.
If unsure, say N.
endmenu endmenu
config CC_HAS_RANDSTRUCT config CC_HAS_RANDSTRUCT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment