mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
kdb: use srcu console list iterator
Guarantee safe iteration of the console list by using SRCU. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Aaron Tomlin <atomlin@atomlin.com> Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20221116162152.193147-15-john.ogness@linutronix.de
This commit is contained in:
parent
12335446e0
commit
b8ef04be6e
@ -545,6 +545,7 @@ static void kdb_msg_write(const char *msg, int msg_len)
|
|||||||
{
|
{
|
||||||
struct console *c;
|
struct console *c;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
int cookie;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (msg_len == 0)
|
if (msg_len == 0)
|
||||||
@ -558,8 +559,20 @@ static void kdb_msg_write(const char *msg, int msg_len)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_console(c) {
|
/*
|
||||||
if (!(c->flags & CON_ENABLED))
|
* The console_srcu_read_lock() only provides safe console list
|
||||||
|
* traversal. The use of the ->write() callback relies on all other
|
||||||
|
* CPUs being stopped at the moment and console drivers being able to
|
||||||
|
* handle reentrance when @oops_in_progress is set.
|
||||||
|
*
|
||||||
|
* There is no guarantee that every console driver can handle
|
||||||
|
* reentrance in this way; the developer deploying the debugger
|
||||||
|
* is responsible for ensuring that the console drivers they
|
||||||
|
* have selected handle reentrance appropriately.
|
||||||
|
*/
|
||||||
|
cookie = console_srcu_read_lock();
|
||||||
|
for_each_console_srcu(c) {
|
||||||
|
if (!(console_srcu_read_flags(c) & CON_ENABLED))
|
||||||
continue;
|
continue;
|
||||||
if (c == dbg_io_ops->cons)
|
if (c == dbg_io_ops->cons)
|
||||||
continue;
|
continue;
|
||||||
@ -577,6 +590,7 @@ static void kdb_msg_write(const char *msg, int msg_len)
|
|||||||
--oops_in_progress;
|
--oops_in_progress;
|
||||||
touch_nmi_watchdog();
|
touch_nmi_watchdog();
|
||||||
}
|
}
|
||||||
|
console_srcu_read_unlock(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
|
int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
|
||||||
|
Loading…
Reference in New Issue
Block a user