Patch "panic: Introduce warn_limit" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    panic: Introduce warn_limit

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     panic-introduce-warn_limit.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From stable-owner@xxxxxxxxxxxxxxx Fri Feb  3 01:35:49 2023
From: Eric Biggers <ebiggers@xxxxxxxxxx>
Date: Thu,  2 Feb 2023 16:33:51 -0800
Subject: panic: Introduce warn_limit
To: stable@xxxxxxxxxxxxxxx
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, SeongJae Park <sj@xxxxxxxxxx>, Seth Jenkins <sethjenkins@xxxxxxxxxx>, Jann Horn <jannh@xxxxxxxxxx>, "Eric W . Biederman" <ebiederm@xxxxxxxxxxxx>, linux-hardening@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Jonathan Corbet <corbet@xxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>, "Jason A. Donenfeld" <Jason@xxxxxxxxx>, Eric Biggers <ebiggers@xxxxxxxxxx>, Huang Ying <ying.huang@xxxxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>, tangmeng <tangmeng@xxxxxxxxxxxxx>, "Guilherme G. Piccoli" <gpiccoli@xxxxxxxxxx>, Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>, Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>, linux-doc@xxxxxxxxxxxxxxx, Luis Chamberlain <mcgrof@xxxxxxxxxx>
Message-ID: <20230203003354.85691-13-ebiggers@xxxxxxxxxx>

From: Kees Cook <keescook@xxxxxxxxxxxx>

commit 9fc9e278a5c0b708eeffaf47d6eb0c82aa74ed78 upstream.

Like oops_limit, add warn_limit for limiting the number of warnings when
panic_on_warn is not set.

Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Cc: "Jason A. Donenfeld" <Jason@xxxxxxxxx>
Cc: Eric Biggers <ebiggers@xxxxxxxxxx>
Cc: Huang Ying <ying.huang@xxxxxxxxx>
Cc: Petr Mladek <pmladek@xxxxxxxx>
Cc: tangmeng <tangmeng@xxxxxxxxxxxxx>
Cc: "Guilherme G. Piccoli" <gpiccoli@xxxxxxxxxx>
Cc: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: linux-doc@xxxxxxxxxxxxxxx
Reviewed-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20221117234328.594699-5-keescook@xxxxxxxxxxxx
Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 Documentation/sysctl/kernel.txt |   10 ++++++++++
 kernel/panic.c                  |   27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -94,6 +94,7 @@ show up in /proc/sys/kernel:
 - threads-max
 - unprivileged_bpf_disabled
 - unknown_nmi_panic
+- warn_limit
 - watchdog
 - watchdog_thresh
 - version
@@ -1072,6 +1073,15 @@ example.  If a system hangs up, try pres
 
 ==============================================================
 
+warn_limit:
+
+Number of kernel warnings after which the kernel should panic when
+``panic_on_warn`` is not set. Setting this to 0 disables checking
+the warning count. Setting this to 1 has the same effect as setting
+``panic_on_warn=1``. The default value is 0.
+
+==============================================================
+
 watchdog:
 
 This parameter can be used to disable or enable the soft lockup detector
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -39,6 +39,7 @@ static int pause_on_oops_flag;
 static DEFINE_SPINLOCK(pause_on_oops_lock);
 bool crash_kexec_post_notifiers;
 int panic_on_warn __read_mostly;
+static unsigned int warn_limit __read_mostly;
 
 int panic_timeout = CONFIG_PANIC_TIMEOUT;
 EXPORT_SYMBOL_GPL(panic_timeout);
@@ -47,6 +48,26 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list
 
 EXPORT_SYMBOL(panic_notifier_list);
 
+#ifdef CONFIG_SYSCTL
+static struct ctl_table kern_panic_table[] = {
+	{
+		.procname       = "warn_limit",
+		.data           = &warn_limit,
+		.maxlen         = sizeof(warn_limit),
+		.mode           = 0644,
+		.proc_handler   = proc_douintvec,
+	},
+	{ }
+};
+
+static __init int kernel_panic_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_panic_table);
+	return 0;
+}
+late_initcall(kernel_panic_sysctls_init);
+#endif
+
 static long no_blink(int state)
 {
 	return 0;
@@ -124,8 +145,14 @@ EXPORT_SYMBOL(nmi_panic);
 
 void check_panic_on_warn(const char *origin)
 {
+	static atomic_t warn_count = ATOMIC_INIT(0);
+
 	if (panic_on_warn)
 		panic("%s: panic_on_warn set ...\n", origin);
+
+	if (atomic_inc_return(&warn_count) >= READ_ONCE(warn_limit) && warn_limit)
+		panic("%s: system warned too often (kernel.warn_limit is %d)",
+		      origin, warn_limit);
 }
 
 /**


Patches currently in stable-queue which might be from stable-owner@xxxxxxxxxxxxxxx are

queue-4.14/panic-unset-panic_on_warn-inside-panic.patch
queue-4.14/objtool-add-a-missing-comma-to-avoid-string-concatenation.patch
queue-4.14/hexagon-fix-function-name-in-die.patch
queue-4.14/exit-add-and-use-make_task_dead.patch
queue-4.14/h8300-fix-build-errors-from-do_exit-to-make_task_dead-transition.patch
queue-4.14/panic-consolidate-open-coded-panic_on_warn-checks.patch
queue-4.14/exit-put-an-upper-limit-on-how-often-we-can-oops.patch
queue-4.14/panic-introduce-warn_limit.patch
queue-4.14/exit-allow-oops_limit-to-be-disabled.patch
queue-4.14/ia64-make-ia64_mca_recovery-bool-instead-of-tristate.patch
queue-4.14/exit-use-read_once-for-all-oops-warn-limit-reads.patch
queue-4.14/exit-expose-oops_count-to-sysfs.patch
queue-4.14/panic-expose-warn_count-to-sysfs.patch
queue-4.14/docs-fix-path-paste-o-for-sys-kernel-warn_count.patch
queue-4.14/sysctl-add-a-new-register_sysctl_init-interface.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux