File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Documentation/admin-guide/sysctl Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1509,6 +1509,16 @@ entry will default to 2 instead of 0.
150915092 Unprivileged calls to ``bpf() `` are disabled
15101510= =============================================================
15111511
1512+
1513+ warn_limit
1514+ ==========
1515+
1516+ Number of kernel warnings after which the kernel should panic when
1517+ ``panic_on_warn `` is not set. Setting this to 0 disables checking
1518+ the warning count. Setting this to 1 has the same effect as setting
1519+ ``panic_on_warn=1 ``. The default value is 0.
1520+
1521+
15121522watchdog
15131523========
15141524
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ bool crash_kexec_post_notifiers;
5858int panic_on_warn __read_mostly ;
5959unsigned long panic_on_taint ;
6060bool panic_on_taint_nousertaint = false;
61+ static unsigned int warn_limit __read_mostly ;
6162
6263int panic_timeout = CONFIG_PANIC_TIMEOUT ;
6364EXPORT_SYMBOL_GPL (panic_timeout );
@@ -88,6 +89,13 @@ static struct ctl_table kern_panic_table[] = {
8889 .extra2 = SYSCTL_ONE ,
8990 },
9091#endif
92+ {
93+ .procname = "warn_limit" ,
94+ .data = & warn_limit ,
95+ .maxlen = sizeof (warn_limit ),
96+ .mode = 0644 ,
97+ .proc_handler = proc_douintvec ,
98+ },
9199 { }
92100};
93101
@@ -203,8 +211,14 @@ static void panic_print_sys_info(bool console_flush)
203211
204212void check_panic_on_warn (const char * origin )
205213{
214+ static atomic_t warn_count = ATOMIC_INIT (0 );
215+
206216 if (panic_on_warn )
207217 panic ("%s: panic_on_warn set ...\n" , origin );
218+
219+ if (atomic_inc_return (& warn_count ) >= READ_ONCE (warn_limit ) && warn_limit )
220+ panic ("%s: system warned too often (kernel.warn_limit is %d)" ,
221+ origin , warn_limit );
208222}
209223
210224/**
You can’t perform that action at this time.
0 commit comments