exit: Allow oops_limit to be disabled
PATCH 1/1 exit: Allow oops_limit to be disabled
In preparation for keeping oops_limit logic in sync with warn_limit, have oops_limit == 0 disable checking the Oops counter.
Cc Jann Horn <[email protected]>
Cc Seth Jenkins <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Baolin Wang <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Huang Ying <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Signed-off-by Kees Cook <[email protected]>
---
I've changed the warn_limit logic to match...
--- Documentation/admin-guide/sysctl/kernel.rst | 5 +++-- kernel/exit.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
Documentation/admin-guide/sysctl/kernel.rst +3 -2
@@ -671,8 +671,9 @@ oops_limit ========== Number of kernel oopses after which the kernel should panic when -``panic_on_oops`` is not set. Setting this to 0 or 1 has the same effect -as setting ``panic_on_oops=1``. +``panic_on_oops`` is not set. Setting this to 0 disables checking +the count. Setting this to 1 has the same effect as setting +``panic_on_oops=1``. The default value is 10000. osrelease, ostype & version
kernel/exit.c +1 -1
@@ -954,7 +954,7 @@ void __noreturn make_task_dead(int signr)* To make sure this can't happen, place an upper bound on how often the * kernel may oops without panic(). */ -if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit)) +if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit) && oops_limit)panic ("Oopsed too often (kernel.oops_limit is %d)" , oops_limit);/*
Signature · 1 line
2.34.1
kernel/exit.c void __noreturn make_task_dead(int signr) · line 959
Quoted 10 lines · Kees Cook
kernel/exit.c +1
-1@@ -954,7 +954,7 @@ void __noreturn make_task_dead(int signr)* To make sure this can't happen, place an upper bound on how often the * kernel may oops without panic(). */ -if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit)) +if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit) && oops_limit)panic ("Oopsed too often (kernel.oops_limit is %d)" , oops_limit);
That's dodgy, please write as:
limit = READ_ONCE(oops_limit); if (atomic_inc_return(&oops_count) >= limit && limit)
So we don't explicitly add a reload that negates the whole READ_ONCE().
Quoted 15 lines · Peter Zijlstra
kernel/exit.c void __noreturn make_task_dead(int signr) · line 959
Quoted 10 lines · Kees Cook
kernel/exit.c +1
-1@@ -954,7 +954,7 @@ void __noreturn make_task_dead(int signr)* To make sure this can't happen, place an upper bound on how often the * kernel may oops without panic(). */ -if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit)) +if (atomic_inc_return (&oops_count) >=READ_ONCE (oops_limit) && oops_limit)panic ("Oopsed too often (kernel.oops_limit is %d)" , oops_limit);That's dodgy, please write as:
Quoted 4 lines
limit = READ_ONCE(oops_limit); if (atomic_inc_return(&oops_count) >= limit && limit)So we don't explicitly add a reload that negates the whole
READ_ONCE().
Yup, that's more correct. Sent:
https://lore.kernel.org/lkml/[email protected]
Signature · 1 line
Kees Cook