From nobody Fri Oct 2 12:20:43 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B64DE42DA30 for ; Fri, 31 Jul 2026 14:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785508346; cv=none; b=HgF3EV/gIOQOjOIJ0FhIq9IpXt8uzwaa4t1ZHiWeCDkYXULxGv7QtDDFOK9APpXYmhmz1X2w/rIUlfmWLm8DTuY4VGAbwt2HMqSoNrywmF1Z+KNSuUG1v4pzR+HetraAyT+fwjQTUtav29bv5wIAPkkTR5rYSBiMR9lGWxSXA1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785508346; c=relaxed/simple; bh=UyQV4DBtWFb66EVOhQFQ6CmJw9LI4+ardnI6Y8Jv5AQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jJtVb0itFfliiQlQ7owD/I7X6iuRhCNZIi/O6AlYv4yVpETmfzXmD3v+9bUrvqoEJvA2eEZkleTtx8Fj31AjOsQen+E1pnCvGar8xry8ui9UmHSxxgvRWKgj/neFzKyb3KchgbkDagtVeygv4PuYoYofphhJYrPFFaA8V6DENFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SQzmZCiy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jkLuu7KQ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SQzmZCiy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jkLuu7KQ" From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785508339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DfE+XPAFQynO+XIHj3X1ZUY4xAD+Kd3w+iGELi+kDjA=; b=SQzmZCiy+iGsujfbsNpnmfDM6wEbAMjgc+JYKdvlZM5izV2u+s02O9T8sM8i+v5sZtWC9G op/Fbyg97Yu2oc4sv+WqLOZZxwVV8dfWkSZbLMXrfvVVZswqC9eiUOkw+JWej9aM7hCQFf OE/u8FkYw9BQujal342jYJ0izSCd3yLMf1V9YZC8RL6Q8N5mi9g3x6hQJpg7IO4plw6d+V iaywN9JVtZFyj6cYsxLOPL7y9FGssjPic0qikohkzYGBkkuWfo6fvxJqknT7AQ3zYBR57R eSOeuBBOBmOuRTEnlCFwXiQyIke6l7P/mk2NTlj0NCpQ8zm/igwPwu51SUfs8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785508339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DfE+XPAFQynO+XIHj3X1ZUY4xAD+Kd3w+iGELi+kDjA=; b=jkLuu7KQhVxmF85glYk7zi3Lr/24esULjc/Pi+y9hAVTP/h+tg4PQE5+r0ZaarYIwy4Sno hBCUmtg2qAubcYCg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org Subject: [PATCH printk] printk/nbcon: WARN on unsafe reentrance Date: Fri, 31 Jul 2026 16:37:41 +0206 Message-ID: <20260731143219.592300-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Link: https://lore.kernel.org/lkml/87o6fwms02.fsf@jogness.linutronix.de --- kernel/printk/nbcon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index 4b03b019cd5ee..4849f0d1b13b3 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -838,6 +838,9 @@ static bool __nbcon_context_update_unsafe(struct nbcon_= context *ctxt, bool unsaf nbcon_state_read(con, &cur); =20 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 --=20 2.47.3