printk/nbcon: WARN on unsafe reentrance
John Ogness
maintainerPATCH 1/1 printk/nbcon: WARN on unsafe reentrance
Since the nbcon unsafe enter/exit functions are simply toggling a state boolean, a buggy nbcon driver might enter an unsafe section when the context is already in an unsafe section and it would go unnoticed, even though doing so is a bug. Unsafe sections are not reentrant!
Add a WARN_ON_ONCE() to nbcon_enter_unsafe() if the context is already in an unsafe section.
Signed-off-by John Ogness <[email protected]>
--- kernel/printk/nbcon.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/printk/nbcon.c +3 -0
@@ -838,6 +838,9 @@ static bool __nbcon_context_update_unsafe(struct nbcon_context *ctxt, bool unsafnbcon_state_read (con, &cur); do { + /* Unsafe sections are not reentrant. */ + WARN_ON_ONCE(unsafe && cur.unsafe); + /* * The unsafe bit must not be cleared if an * unsafe hostile takeover has occurred.
base-commit: 703a9d76a45dd97b19b2432fc1ba4beb4d67a94f
Signature · 1 line
2.47.3