From nobody Mon Apr 6 23:16:46 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 B4B543ACA42 for ; Tue, 17 Mar 2026 11:41:42 +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=1773747703; cv=none; b=kuqutrho7pSw5Za4N4X2tM2tdJ6eW9QaWVNnDntinzg0Yw65lOC9ugqfZvFOoteU/O3rzMiTCKuWSxaRhWVLBvJk3BYstUhAwUOwRzjcYVtKFo0XneOZ42MRROSoY50Ew6U0Tql2FgTqmlkLit0y4eGnbOwjh4coXunYSqUPK4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773747703; c=relaxed/simple; bh=EgSylJqIafcDFcb2jExOnv9AzrbJQdJUIvdp5YJprEs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=CidCXvX19bv8K9Un4Y4SLfZ7GF+pRGgN/tZU3c7cPY85zZTZyXCgvbJlodaWBu6qA1Psm6mYdGkWEGotBMue9Xq6cP5fDgYbgtPU7O6LMdi5FlVGtvtpIRUgWB8fssC9T7c6oQCAJR0/5z7JAX+HdO6rvp8si4V04Mf76dCGiDM= 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=CY8VcIjz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WCENfc7b; 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="CY8VcIjz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WCENfc7b" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773747701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XIVnIznI36yzcSoHbmhDRPJcxNtZDFxEHD+uTCcR96w=; b=CY8VcIjzQdV9bzYzLGLTYbjm3SWu9AQYy2Ub8ru2Of9Bwoc5AnQKOBsvyIXPZc5PlG6Zql iku5gjXAXt/DebRAeMIxrtlPFrd4ndm0pTFGYZoOrRlBTD7xfk68Yt1gcqC9joXNAFqjmh P6zLvUOBEVt3myv8sodc130+7nBwRrIGu/9xdn/xkyL5p/3Zst+a1rQZ3C3R5I8tFpKU9a XzpEspyDYe3W70Xx2BKQtT5P6dYgBTSbecVNGrCowoViSOCSPnwaZzvk2lgfcqPNBXHkGu 4q6ro8uCSXGZXhEwCtlhQvwMz8FOijgTXPeuAHDb6L+FYnRtrwln4eh7XkwnQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773747701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XIVnIznI36yzcSoHbmhDRPJcxNtZDFxEHD+uTCcR96w=; b=WCENfc7bmdcJH+h1hfuelwjItDWxJbEduGglPJKBB8zyE14/eAH8ZljuaSkSJ7mkAqLFOY 69RXymFsHaF7Q8BQ== Date: Tue, 17 Mar 2026 12:41:23 +0100 Subject: [PATCH] lib/vsprintf: Validate sleepable context during restrictred pointer formatting Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260317-restricted-pointers-final-v1-1-b4dca0ed6483@linutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MMQqAMAxA0atIZgO1qEWvIg7SphqQKkkRQby7x fEN/z+gJEwKY/WA0MXKRypo6gr8tqSVkEMxWGN70xiHQpqFfaaA58EpkyhGTsuOPth2cEMMrrN Q+lMo8v2/p/l9P7nxPIZrAAAA X-Change-ID: 20260107-restricted-pointers-final-cd24979fd752 To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773747700; l=1728; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=EgSylJqIafcDFcb2jExOnv9AzrbJQdJUIvdp5YJprEs=; b=HGvrmNwEZfkI1lcKVvXzeHZHd8O4POtHpk5osUaHQDvF1AwE05oqri8+GcjUCzw5yvjvbw10e sMbPP3QJPyzDozfl/cWskEl+anfRCfpSpg0xBIUEVSpRWdTvlXqyRSD X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Depending on the system configuration, the restricted pointer formatting might call into the security subsystem which might sleep. As %pK is intended to be only used from read handlers of virtual files, which always run in task context, this should never happen in practice. However, developers have used %pK before from atomic context without realizing this restriction. While all existing user of %pK through printk() have been removed, new ones might be reintroduced accidentally in the future. Add a might_sleep(), so that misuse of %pK from atomic context is detected right away. Link: https://lore.kernel.org/lkml/20250113171731-dc10e3c1-da64-4af0-b767-7= c7070468023@linutronix.de/ Link: https://lore.kernel.org/lkml/20241217142032.55793-1-acarmina@redhat.c= om/ Signed-off-by: Thomas Wei=C3=9Fschuh --- This depends on commit 5886cc8f895b ("drm/msm/dpu: Don't use %pK through printk (again)"), which was merged in v7.0-rc2. --- lib/vsprintf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 800b8ac49f53..eb9dbb28fb9b 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -862,6 +862,9 @@ static noinline_for_stack char *restricted_pointer(char *buf, char *end, const void *ptr, struct printf_spec spec) { + /* Only usable from task context, The call to has_capability_noaudit() mi= ght sleep. */ + might_sleep(); + switch (kptr_restrict) { case 0: /* Handle as %p, hash and do _not_ leak addresses. */ --- base-commit: 2d1373e4246da3b58e1df058374ed6b101804e07 change-id: 20260107-restricted-pointers-final-cd24979fd752 Best regards, --=20 Thomas Wei=C3=9Fschuh