diff options
| author | John Ogness <john.ogness@linutronix.de> | 2026-10-30 15:03:55 +0106 |
|---|---|---|
| committer | Petr Mladek <pmladek@suse.com> | 2026-11-03 14:42:58 +0100 |
| commit | 8a7f26aa072a4e63bc3b1adfe649546709db722e (patch) | |
| tree | 0c62c93e4411d2b16476c5911c8d6815269777f8 /tools/perf/scripts/python/Perf-Trace-Util/lib/Perf | |
| parent | 9ead26a7593e08c3f3661f29f24e6d002133a92b (diff) | |
printk: Avoid multiple unregistration in unregister_console_locked()
unregister_console_locked() is called from within
hlist_for_each_entry_safe(console_list) loops. This would be safe if
unregister_console_locked() only unregistered the specified console. After
all, that is what the _safe variant is for.
However, unregister_console_locked() calls printk_kthreads_check_locked(),
which can unregister _multiple_ consoles if kthreads fail to start. This
could lead to hlist_for_each_entry_safe() use-after-free scenarios because
not only was the list entry removed, but possibly the following entry as
well (the @n temporary storage of the next entry).
Move the call to printk_kthreads_check_locked() outside of
unregister_console_locked(). Add comments to both functions to clarify
if they are safe to be used in hlist_for_each_entry_safe(console_list)
loops.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/lkml/87ik31iz4x.fsf@jogness.linutronix.de
Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Derek Barbosa <debarbos@redhat.com>
Link: https://patch.msgid.link/20261030135802.663893-1-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/lib/Perf')
0 files changed, 0 insertions, 0 deletions
