From nobody Thu Jun 11 21:24:22 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 701B93CC31A for ; Mon, 8 Jun 2026 14:21:47 +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=1780928508; cv=none; b=NRYwXGHBoYFQ7NIGwoMSaTAtPxpKt481aMvDizK7ytYgLQFqhGslty6Eubsg08Aj46RLisGLCapjXxNBzOWNg3x2o/UrQYlVogt/ft8LeylKx0+4oLFck5wbIKQZc8stsJAFRzwHY5guS1hzPnsvqXWcuYTSkq04+TIN+cSZ9B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928508; c=relaxed/simple; bh=AkYj5AHtrC/uF53D3aGzzwsC2RGoqU7NdyGliCiAltE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TiuUGejkCCxqXgQHGIKlpnMtYeACHGgAQa4E1xFNJwjx6X1omKztrMSQIZDSVPWqrZi0USQGRpiIVrf1OEq5Uo3X8dK82dShBxtHdjbPBVXW87cd+yglm8DPP8LJfutsFeK9JcUxwU3ZoJRy6mCMn+otn/UsLNNd2SikOeJfGe0= 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=hBRoG8Zo; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=swxE7ihq; 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="hBRoG8Zo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="swxE7ihq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780928506; 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: in-reply-to:in-reply-to:references:references; bh=tAloKRgByKT+tR/NHbf2IcJ2ZEGz+DigBWOf/M55hSA=; b=hBRoG8ZoU+7DPdo2VGjNTKX0byeGCNXsR6cd1NCeENj1ZhX09A41ei+cGsboT0j3MA+JOh ClBQdT/ce5eb042OkgMgHFatTTX6W+rwUoW4t9vI+XgbvkD8IbfkbyDKt/2OLKDiSTTg4F vhEs1RUsDQgSnBsYYeGAsI0gdDVbDysS+RxVWUJbZwkizL8ve4u8whxgw33kOBB3iaRQ5H Uq3JiOn/P4NTPH+R4o/MxWDCcqI7QVpKkWkbII1Gki7+8zMAeV4ecC1eLvVWLSleJFkT76 Ea+d/oWRg2ZDOpQNCkmH9yJNyC3DNqB6aOkD0g/ClcN0tkQxfV/9Wugng0mBkw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780928506; 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: in-reply-to:in-reply-to:references:references; bh=tAloKRgByKT+tR/NHbf2IcJ2ZEGz+DigBWOf/M55hSA=; b=swxE7ihqTpiY7nOCE+H2qDYVeqrnsDr9YnQkQgMYGw1UKXAcvfxPQ84MSy2lWGTzk3CWGh RMeSvTaamSysKjBQ== Date: Mon, 08 Jun 2026 16:21:41 +0200 Subject: [PATCH v4 1/5] locking/lockdep: Add a helper to validate the locking context without a lock 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: <20260608-restricted-pointers-final-v4-1-9a436615799e@linutronix.de> References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> In-Reply-To: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Sebastian Andrzej Siewior , Clark Williams , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1780928505; l=1669; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=AkYj5AHtrC/uF53D3aGzzwsC2RGoqU7NdyGliCiAltE=; b=YnGcL7veYxjdmGNkarldtLIpJtAcjUgRhGWlvdPBZoGclDU+xcfOVphcAsRhPYNLVDb+OLWiB 5D4Z7l+3vL4AJ/szNpx0lbOZq/KqSoTzarHxUoDAC7lGpdVs/wSCw3t X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= In some cases the specific codepath and its locking operations depend on the runtime configuration of the system. lockdep will only detect lock misuse if the system is configured in the right way by chance. To make lockdep more reliable in these cases, introduce a helper macro to define a lockdep map without any corresponding lock. This differs from the related DEFINE_WAIT_OVERRIDE_MAP() as the context of the map is checked against the current locking context. Link: https://lore.kernel.org/lkml/20241217142032.55793-1-acarmina@redhat.c= om/ Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/lockdep.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 621566345406..ae3e332f1518 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -315,6 +315,11 @@ extern void lock_unpin_lock(struct lockdep_map *lock, = struct pin_cookie); .wait_type_inner =3D _wait_type, \ .lock_type =3D LD_LOCK_WAIT_OVERRIDE, } =20 +#define DEFINE_WAIT_ASSERT_MAP(_name, _wait_type) \ + struct lockdep_map _name =3D { \ + .name =3D #_name "-wait-type-assert", \ + .wait_type_inner =3D _wait_type, } + #else /* !CONFIG_LOCKDEP */ =20 static inline void lockdep_init_task(struct task_struct *task) @@ -407,6 +412,9 @@ extern int lockdep_is_held(const void *); #define DEFINE_WAIT_OVERRIDE_MAP(_name, _wait_type) \ struct lockdep_map __maybe_unused _name =3D {} =20 +#define DEFINE_WAIT_ASSERT_MAP(_name, _wait_type) \ + struct lockdep_map __maybe_unused _name =3D {} + #endif /* !LOCKDEP */ =20 #ifdef CONFIG_PROVE_LOCKING --=20 2.54.0 From nobody Thu Jun 11 21:24:22 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 0122E3CCFB0 for ; Mon, 8 Jun 2026 14:21:47 +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=1780928509; cv=none; b=XRM2Rt7F7mWtkUtXY0J9WhJ3YbWlVYp95DdvvcQvNC8O+6XHcbc4uR3j1wk7dDLslT8yRLodsSLdvN6LBqCLY/AI1o1c+i7Jzw+WAcvzpl5nHrX+spNgEEIUADv1nGkUYlKMn3OyJA89EiX/27B4GKAQdmnuGe17Q2315SmYeGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928509; c=relaxed/simple; bh=VTtSmlTf4DOzDvKpDdSuJkdCtmRx26UF3OdVKOsA+MI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XbcPQKn8VCTihq/cTf0fi7Wju3WGiLirZfTR4g209pHzkSiSUYXnBqwtaJBhXOim05erVKSwNYIHdimMRcHKjg0hqzunwUL4jiKEMSaYKFUqBP+vUiA9X5FsYqfnmulgKEDlBeQ1Z1vvqcJxW1LKU6MUuKH6t5C7hlW4RnYV/AI= 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=EUlOhAPE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2/6jgsUY; 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="EUlOhAPE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2/6jgsUY" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780928506; 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: in-reply-to:in-reply-to:references:references; bh=jPf/0wI4bhIUl2hLwfCYV4qdPyTepnwIiSC3i8r18ig=; b=EUlOhAPELUiSJdAEPpcBNt8nwqZv6CX8eKsBuulFXtu5RSdZyYZRHcBRUpwPDhbNElRYxx JWs5tMpeP95yzxchrovyPAOdLDDKW5ddcnV2cukK/P2nxxhRNv/6bbj12vBflmNoGp1wc9 yGp6OWYhexxOYqmjTy7RuW2DoJhHZQldA/rrX1SwSY/S2L4am1WCbIwEbIlJipO7uxObKd uyJOrMFWJTVXq2ILQe9vsa4vGW+cb0IFQcP/aizrpTIlpmz0kwZAkeBWj8ABCzBHvp78LL Plf7LLvT1HJgE42ysDIhJNONNpuYul5pGWK2k9mqFtrwrtgqHoCGcZ9KGSq79w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780928506; 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: in-reply-to:in-reply-to:references:references; bh=jPf/0wI4bhIUl2hLwfCYV4qdPyTepnwIiSC3i8r18ig=; b=2/6jgsUYJQHwzil49JxeO5ZSvZLrAKJ/M2G1Mf1Kby2SJYQLhqp8wzHf9m3+McIvvXOZpD 3o8RhFNqZMnkZ8Aw== Date: Mon, 08 Jun 2026 16:21:42 +0200 Subject: [PATCH v4 2/5] locking/lockdep: Add a guard for lock_map_acquire() 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: <20260608-restricted-pointers-final-v4-2-9a436615799e@linutronix.de> References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> In-Reply-To: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Sebastian Andrzej Siewior , Clark Williams , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1780928505; l=938; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=VTtSmlTf4DOzDvKpDdSuJkdCtmRx26UF3OdVKOsA+MI=; b=fXUsFlr5RAs+WfZK6pLVYiLFPAFaTWlA6n65+64fjsx4uNT4/0I5DYis5y9hKPPNxBIzFZ7KO 5dBGBOceTfgAup/m3s/d3Vg4bpuh2t+b8uh2dl0yUV1+7Rj6oLjMtDm X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Make it easy to acquire a lock map based on source code structure. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/lockdep.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index ae3e332f1518..fad8d71e0505 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -10,6 +10,7 @@ #ifndef __LINUX_LOCKDEP_H #define __LINUX_LOCKDEP_H =20 +#include #include #include #include @@ -553,6 +554,8 @@ do { \ #define lock_map_release(l) lock_release(l, _THIS_IP_) #define lock_map_sync(l) lock_sync(l, 0, 0, 1, NULL, _THIS_IP_) =20 +DEFINE_GUARD(lock_map_acquire, struct lockdep_map *, lock_map_acquire(_T),= lock_map_release(_T)) + #ifdef CONFIG_PROVE_LOCKING # define might_lock(lock) \ do { \ --=20 2.54.0 From nobody Thu Jun 11 21:24:22 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 773203CD8B0 for ; Mon, 8 Jun 2026 14:21:48 +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=1780928511; cv=none; b=N4JYXA7ib9qnR2B0Y7llgEekmdqa5v8pYC9BEDoF+wxlKmOihEWkRt6qhMhAxyknLyTXka10mXcga0LMq8VvOpV2I9l96fdeC2a5AHtEOUhgmwPl8cgMo12I+DdsMHvjzyiCFcNFWEuU2na1AX2BNgqVhSaXrtKjBEzf4MkaGQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928511; c=relaxed/simple; bh=5Nz2QAJkB/H07KyO3l85HCsLerC2eMRAuUu6NWvgaP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DiIgtrCKkq1w+zIuVfMAY9YduYStO3v+YiEmvdbLAZ2EognlaxbmfYuGHyxEvOoPB03JjHMd6B/mhIkcYDM94vprc///434P3Hx1V6lTr8a6Ts3rhbibeoKNnLRl2FQ2HrLwEj011Dm2+/F/fPqGh7KjlY8crRQZoBYb8sFt318= 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=el+vOkJB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=mGNnBco3; 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="el+vOkJB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mGNnBco3" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780928507; 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: in-reply-to:in-reply-to:references:references; bh=nqnPZObhW4el9zMNUdbuV8wjUg6mwApi4YgJpKfJpE4=; b=el+vOkJBbblW9vNwJ0lvACMGa1jc2VWYVVa8nAo5vZRS3CWTwmB/trDi9ZZgK8DsT0hmra qe58VuHGmtd9DGTLZN6w2uxkuZW9NKfUw+d6uOQwakt60MgO4vMWAxKloqvVkoDjlieBDb gPyq+Gk2uig4IoQ2srngzAgF03MuKLM2OhKiEq4A7NuzmoQVLYV9kBDLIX5ji1aXKksg7F qug95E806KdQfFCTgNy9JXTGXvaxsyiK1zc6r0RvuPHtRKxTvDhf9j5dzU2id1WrR/Hvdh uNoAotW5Hso4r9Qo3K9uxfOVjqueuayTjFlJVNsp7BRHyMV+LQFfoM7knfA0gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780928507; 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: in-reply-to:in-reply-to:references:references; bh=nqnPZObhW4el9zMNUdbuV8wjUg6mwApi4YgJpKfJpE4=; b=mGNnBco31usPDxHd3COCxIWmjhfV1A7xr9J2/jVs/wKMC361eHvl23XHetzItpOhsyZ7Ew kWpq86S2OWF7QVBg== Date: Mon, 08 Jun 2026 16:21:43 +0200 Subject: [PATCH v4 3/5] lib/vsprintf: Use in_task() for restricted pointer context check 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: <20260608-restricted-pointers-final-v4-3-9a436615799e@linutronix.de> References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> In-Reply-To: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Sebastian Andrzej Siewior , Clark Williams , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1780928505; l=952; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=5Nz2QAJkB/H07KyO3l85HCsLerC2eMRAuUu6NWvgaP8=; b=S6u3eOY7QuoEqaZMq8W1yEluiCU5E9tmqMWrN6JhcuAQF7txkMo3HNj5g4taS0nbZwKBPVDof RlKiO/+VQELDrgtmIWq15nWmsNyz/kN6BFpyMBOKCSQ5a5hDZ6UXowg X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= in_task() is a easier to read and slightly more efficient variant of the existing tests. Suggested-by: Peter Zijlstra Link: https://lore.kernel.org/lkml/20260504130044.GU3126523@noisy.programmi= ng.kicks-ass.net/ Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 33e0778fca52..6095b5f0d022 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -874,7 +874,7 @@ char *restricted_pointer(char *buf, char *end, const vo= id *ptr, * kptr_restrict=3D=3D1 cannot be used in IRQ context * because its test for CAP_SYSLOG would be meaningless. */ - if (in_hardirq() || in_serving_softirq() || in_nmi()) { + if (!in_task()) { if (spec.field_width =3D=3D -1) spec.field_width =3D 2 * sizeof(ptr); return error_string(buf, end, "pK-error", spec); --=20 2.54.0 From nobody Thu Jun 11 21:24:22 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 E69253CBE71 for ; Mon, 8 Jun 2026 14:21:48 +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=1780928510; cv=none; b=nFxbUe+l5GR3lgemOquoA1SWlg6Q3FWJbmJ79LgXjFmyWAyJNaNy2tG3TzvwhB7MSiYOjUBScanbSLr5rnXYbEB+Tm91n6Wn447f4G3DOjU2Txmyrceyw3aOdfLD9aOq/76f+fHTBiiiwGOm2fLEZVa3Gyt/vwrxcddq7dqyclw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928510; c=relaxed/simple; bh=6Q/9ulCqN7kq47L/f080OtZN84Fv3G/xnY1TwiWuXwg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UgLPycecq0aKd9oNnuNS4Vgt43IkF87FwJELlpglgUMfr5Vg8yb9LvnbQPnADK7uVOWQQLOD/1Rhbm7IcwGGnw2FjtTKMmlgHsA8O1uzdrl4PRwvNUfgOWismh8KqUpdzHZDQWuhWNfUWolhYtNwNmmmCu1jLi4TClGt9xkdwW0= 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=HUWDtFU1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9mIWTHre; 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="HUWDtFU1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9mIWTHre" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780928507; 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: in-reply-to:in-reply-to:references:references; bh=yOjoJ2GXJXyNfZG6fkhX9EjF0PqxBF6e5FrhpqCKuD0=; b=HUWDtFU1a6nEMo/eYYXkne+g/ySXXkDiKZzsxBxb7EX+ylX+Ep42JZIj5Mhpt69hn25eGu FsZ61omsBvoporfn66kzeD4j0eRPenJaFPKcJmXxxYxBgYSE1KMUJCd0CNsCN7ZWEdDLah p7ucvoWhTifamfdMpT186ObxOMJmAEK8NUaSqo7AAL/qxHcPjhv5ExCbWBIxWySFDFrvgU jpnRLwX9K1wnlz7/eoOPDYQzAh6UE9azaGB0UJNazwi8AyT58ClGhMHWVw5LPqoQmdrrUu Fu0ZdmFNKrxPsN6nBmu5yALP2UPxYYcs3WYfJtA6gZSPEbr01woBDAzMWOUAlA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780928507; 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: in-reply-to:in-reply-to:references:references; bh=yOjoJ2GXJXyNfZG6fkhX9EjF0PqxBF6e5FrhpqCKuD0=; b=9mIWTHreQg2kfOZrohmfzfKAGcNjfyV2ebBHQkyMqvedlFx7KO0ubFnjtdZRCY97KwqKpv vyndSRKhHub8eEDA== Date: Mon, 08 Jun 2026 16:21:44 +0200 Subject: [PATCH v4 4/5] lib/vsprintf: Always check interrupt context restrictions 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: <20260608-restricted-pointers-final-v4-4-9a436615799e@linutronix.de> References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> In-Reply-To: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Sebastian Andrzej Siewior , Clark Williams , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1780928505; l=1099; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=6Q/9ulCqN7kq47L/f080OtZN84Fv3G/xnY1TwiWuXwg=; b=lxOL3lH4djT2DFcaKyVr48gtphP2otoqYe5K04EThcRETgH/kMDkv/JWwoZt4Oi2IgSbXNxW2 L/oSjeuXGMmC3wf8jW4Yhxmn6DG5U04RcQNa0F2i3IGEnhbL19XwaNq X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= When kptr_restrict is set to '1' restricted pointers can only be used in task context. As kptr_restrict can change at any time at runtime, this means that restricted pointers can only be used from task context in general. Add an assertion to detect misuse early, independently of the current runtime configuration. Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vsprintf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6095b5f0d022..09e0e5194d41 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -863,6 +864,8 @@ static noinline_for_stack char *restricted_pointer(char *buf, char *end, const void *ptr, struct printf_spec spec) { + lockdep_assert(in_task()); + switch (kptr_restrict) { case 0: /* Handle as %p, hash and do _not_ leak addresses. */ --=20 2.54.0 From nobody Thu Jun 11 21:24:22 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 486293CF02D for ; Mon, 8 Jun 2026 14:21:50 +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=1780928511; cv=none; b=CGLwOKvFgG1pYXcCXVunmDt8lAIApqO5AnuQzRyrZGIVFp5MG57fKT9nZwDr2g/AUEOlVe4Jv0hg7xAYIh1eyRutBRlZTypZ9sX8kYW8wXA/jxiIGIMaUeGRhw3GY3BAG3f693cBKMuxCA/Y2/5QDXZZKVBlk3XJ38oSI0kOyXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780928511; c=relaxed/simple; bh=M6cWIuBYmnEz8STtik/V00y/7Xg8RuWOIvf5O2pFl8M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MTLKVIaJp/J1OLIUUSiKGdMgdmOsI9ezOMjHRpk2wfiH73vfR8MEIfyVDddHoU2x4ODiLuMkWm0WYziSVc3YGjDmaSPn4BewNmz7H/jbfzsy/MxY1op8lJzKrvG5msKNrWWNf+Dk7WxBVsBrLr/gVLyypwuDHJPJu33caBJyEJk= 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=ZDb0Ulxi; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NG8BTgZR; 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="ZDb0Ulxi"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NG8BTgZR" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780928508; 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: in-reply-to:in-reply-to:references:references; bh=X7W+MRuoH3ZGaCldnwhU19nMaYlneJ/8geVf9JU0C+w=; b=ZDb0UlxitRXCFs80f/Gc3AoPM995zs9/P1J10FypRSoTaDjqYXBJZeMhQzkJGQbnV3QvzL naLqZLzGEQ7NPGvuQnTKQ1PKUyeDMUeIUkJivpIu0N2fHEQ1hWfaZ/htTv2sBe8fCuAdwm AzADUFfKmOuM43ab+tyyQmLER6P39Kgeq472iv6vevc08LsA9AyVFqNuGHbKwpiGrlfSo4 qyp54cr80HkygUnj+hIIw17Gt5wT07w/77odZAH1Xw8m8ADga9MBIR9rq3ardalbKnrpnr APkfrF5U/BQhKBxip6vhy3ZRCYy0lV2J15KjhmoYDCeeLM9CWfTiCfWouRtBNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780928508; 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: in-reply-to:in-reply-to:references:references; bh=X7W+MRuoH3ZGaCldnwhU19nMaYlneJ/8geVf9JU0C+w=; b=NG8BTgZR/2fZ3nSStiNchaRBdWaThvrs0MIHBBTSaveBawmuxt32ZAPgWH73QDmaThb54+ tvVtccB/15Lm9iAA== Date: Mon, 08 Jun 2026 16:21:45 +0200 Subject: [PATCH v4 5/5] lib/vsprintf: Validate spinlock context during restricted 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: <20260608-restricted-pointers-final-v4-5-9a436615799e@linutronix.de> References: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> In-Reply-To: <20260608-restricted-pointers-final-v4-0-9a436615799e@linutronix.de> To: Andrew Morton , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Sebastian Andrzej Siewior , Clark Williams , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1780928505; l=2053; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=M6cWIuBYmnEz8STtik/V00y/7Xg8RuWOIvf5O2pFl8M=; b=iDj1AZALpfrUczZFylj08SzrIopeztbQ8wm+nLspcZDP/xos7oNjwT1XHRALbll45dMpvsyYh JBwW0jS/iHLCubXnDafZIJtOO6wZa7O43fHBgXy2BKfuhg4uDb32M8V 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 takes spinlocks, which might sleep under PREEMPT_RT. As %pK is intended to be only used from read handlers of virtual files, which always run in task context, this should not be a problem 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 lockdep annotation to unconditionally introduce a fake spinlock in restricted_pointer(), so lockdep can detect misuse even if the current test system configuration would not exhibit the issue. This is intentionally a single lock instance shared by all callers, as that mirrors what can happen in the security subsystem. This check comes intentionally after the in_task() one, to have the clearer diagnostic first when the function is called from IRQ context, which will trigger both. 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 Reviewed-by: Petr Mladek --- lib/vsprintf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 09e0e5194d41..728a1acd69ae 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -864,7 +864,14 @@ static noinline_for_stack char *restricted_pointer(char *buf, char *end, const void *ptr, struct printf_spec spec) { + /* + * has_capability_noaudit() may use spinlocks. + * Make sure %pK is only used from valid contexts. + */ + static DEFINE_WAIT_ASSERT_MAP(vsprintf_restricted_pointer_map, LD_WAIT_CO= NFIG); + lockdep_assert(in_task()); + guard(lock_map_acquire)(&vsprintf_restricted_pointer_map); =20 switch (kptr_restrict) { case 0: --=20 2.54.0