Skip to contentSkip to conversation

printk/nbcon: WARN on unsafe reentrance

PATCH Superseded John Ogness 1 participant 1 message Jul 31 Printk

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

John Ogness

author maintainer
#0 lore raw

PATCH 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.

---
 kernel/printk/nbcon.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/printk/nbcon.c +3 -0
index 4b03b019cd5ee..4849f0d1b13b3 100644
@@ -838,6 +838,9 @@ static bool __nbcon_context_update_unsafe(struct nbcon_context *ctxt, bool unsaf
 	nbcon_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