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.
1509
1509
2 Unprivileged calls to ``bpf() `` are disabled
1510
1510
= =============================================================
1511
1511
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
+
1512
1522
watchdog
1513
1523
========
1514
1524
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ bool crash_kexec_post_notifiers;
58
58
int panic_on_warn __read_mostly ;
59
59
unsigned long panic_on_taint ;
60
60
bool panic_on_taint_nousertaint = false;
61
+ static unsigned int warn_limit __read_mostly ;
61
62
62
63
int panic_timeout = CONFIG_PANIC_TIMEOUT ;
63
64
EXPORT_SYMBOL_GPL (panic_timeout );
@@ -88,6 +89,13 @@ static struct ctl_table kern_panic_table[] = {
88
89
.extra2 = SYSCTL_ONE ,
89
90
},
90
91
#endif
92
+ {
93
+ .procname = "warn_limit" ,
94
+ .data = & warn_limit ,
95
+ .maxlen = sizeof (warn_limit ),
96
+ .mode = 0644 ,
97
+ .proc_handler = proc_douintvec ,
98
+ },
91
99
{ }
92
100
};
93
101
@@ -203,8 +211,14 @@ static void panic_print_sys_info(bool console_flush)
203
211
204
212
void check_panic_on_warn (const char * origin )
205
213
{
214
+ static atomic_t warn_count = ATOMIC_INIT (0 );
215
+
206
216
if (panic_on_warn )
207
217
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 );
208
222
}
209
223
210
224
/**
You can’t perform that action at this time.
0 commit comments