From nobody Sun Jun 14 02:33:01 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 9564239D6F8 for ; Mon, 4 May 2026 10:47:26 +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=1777891647; cv=none; b=UxXYZEU0v55cUx2zsjHIFfuGftGr87uqfx6tFwHq0EUcQkAyzgenIP71WBvz3282tJ0ViCT7++80kGCfmNtlz5+yC0YMhnzu20YdmEbV3pbIUIFOTLLZxj8ww2wQA2fi+HO+osTxxVc7OMh7ldmcwLJnlCY6wtwgOtij+AP0SJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777891647; c=relaxed/simple; bh=B2QN0SifbMh2La/twhWWaJUTyAryY/YjepycKtDQdkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N9sOJZq083zBpO0d2IyDS05H9M5Mki8wZ/lRMwXD5HAamCcAJYqvjOTZHJ/ydUgh4dgQvBsgaEjD4dKlHvsxbGaF7uLfSODQQTuGvBpH7KjoisymwdSRwtagzYgyJcWCEDA+kpkeVadcittepbOQP0gEp6WXepNeJCuiqFMvxmM= 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=x2wanBuf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nGa7wH8W; 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="x2wanBuf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nGa7wH8W" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777891645; 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=A4tm8pTuwCSr7owNnQdabrJvenrKmBnZOfdXbRtBJzs=; b=x2wanBuf7AjxbV7zhqajkQPqy1OQDfSBTtjTtX2N9QFIWoN0VuzcKGWNxPfeTtERM11fzv NRKekvx2ew7s5OUE8QR+4xJYgnSCuuI9kL+YhYz8HiO6ABF1ufH427qCfdBAmDOrObcjWw j2S8XhxogiFuUPDKlmXIP62LHGf3qS0iK+KbOxPV9wFCWH/wN5vRmUbJbzf3MhOe7cUA9T P/S1dT43p3woFgWPDJ8NXXzTp5GwmvoLSowHyoWOSEO13bV7CkBOxBw1jVvRPwcTwlf0uL K+nQqaY7Micn27ZeqIL6uf9We+NPZI1z0C7Png+IFBoBPWqB4+CxAs5bv2AZUA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777891645; 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=A4tm8pTuwCSr7owNnQdabrJvenrKmBnZOfdXbRtBJzs=; b=nGa7wH8WRfkxCgyVFVHA/5TV1fKYT0CanP17btQ2zE9nY4k4fU30n84hVy6fHom7VlTLtH YtxAtW88PgNku5Cw== Date: Mon, 04 May 2026 12:47:17 +0200 Subject: [PATCH v2 1/4] 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: <20260504-restricted-pointers-final-v2-1-4934933503e5@linutronix.de> References: <20260504-restricted-pointers-final-v2-0-4934933503e5@linutronix.de> In-Reply-To: <20260504-restricted-pointers-final-v2-0-4934933503e5@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=1777891643; l=1669; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=B2QN0SifbMh2La/twhWWaJUTyAryY/YjepycKtDQdkU=; b=oCWTaCgWfjET6njo5KLghv3yqP07FfsTim/Rk2k4ddBeWpzJ/5/I+AVxX+lQCzeo2WdB1QLiz ucwILNnKM55AoWwS/Fe/IncnUHq9m+7BQGySVhOEVn785XMhu3wrgvl 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.53.0 From nobody Sun Jun 14 02:33:01 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 2CB6634C155 for ; Mon, 4 May 2026 10:47:27 +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=1777891648; cv=none; b=CuauCwEATCHDFN+dNjOZzjHq9LrE0xB0IcCEFCJ6Ph+KzSAVcDTMFLeW7jS4iXD2TLQGqWr1NTY61fz6JMhl7hIFXgdtZ/40E/DIEeN1ncvcMqOp0B+RISfzENJbtWciU4/POeKJLieC7fSeOCgV99t20sFOonbPl3vSKKrYEuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777891648; c=relaxed/simple; bh=ZDGPPvXxpxQVBFMBIYUVyjbRBHxHAqyQJ4YiGEenfnI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m9ld8MiJRBIRGnz76CrBvWnetyzQHjEg2Opp870Igtb+Ro+9sVwz6O7jNHkvx/U5CtsI3/Xgi3VYxtc56Xk1eiD+JAI/VcJ/owk0x8FJSCW+XT5VWf/MJ7IZnZYSzlyT59ZV1djeYaI+COeuYeo6LvjpCOb9zzhzxGJhNYrrdSA= 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=zwmVMKkV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4uYMBydS; 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="zwmVMKkV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4uYMBydS" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777891645; 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=OwqF6lAOoZKH+Flkm3e9Ez3upd+JSieyXLkFsktuIM4=; b=zwmVMKkVsIWKhyEkR/97NpcPttcQ8xX/T5BMaLrngf6Owj06o2uvpli8vs2Yg61H9/aXe/ b8fWctQlDgAZXbJG4LChJ+RpkjLoBTEpYPKZd8U7LtwTeYgKTHoxOCT9X9H3A4PwL9m4nM X6IhYkOO+ffmePQLY4lXDw0rsxp2+V/m79sQCpvUYy+i66ahct/vR0VYXyLgn7LtXvnd7g 3Kn9lZUOiLcUSDzoj7RaNEDVEiMac5euVVqO5e82Zgcs0XT3Lm+M9fEliTQsJ4NwZLDLaD 3X/izbU+XqKkX0ecBhjN2RAumalQGeqcGYPUhUYZWrkO229j2SLPEl0p8aZQwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777891645; 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=OwqF6lAOoZKH+Flkm3e9Ez3upd+JSieyXLkFsktuIM4=; b=4uYMBydS/dlko7LnM5IcRH1mgfRDgvZt291UgFpBBq1dj90TW+nMBTLp75ExAK7NcHHl9s VQShjyc/qr3iEkDA== Date: Mon, 04 May 2026 12:47:18 +0200 Subject: [PATCH v2 2/4] 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: <20260504-restricted-pointers-final-v2-2-4934933503e5@linutronix.de> References: <20260504-restricted-pointers-final-v2-0-4934933503e5@linutronix.de> In-Reply-To: <20260504-restricted-pointers-final-v2-0-4934933503e5@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=1777891643; l=938; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=ZDGPPvXxpxQVBFMBIYUVyjbRBHxHAqyQJ4YiGEenfnI=; b=TiTFpyJGySZQqxk3ilStDiF9k4A4kazYDhbxEQIVQ9lbFvfrTqob2fo85tFOB07UqDbwXQeKV 9Irsh+Ut3dnCJcZb3jFVpJzRWIvyaVr5MuA49WF+bIcE7Lt3+ruEBaz 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.53.0 From nobody Sun Jun 14 02:33:01 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 AB7E938C427 for ; Mon, 4 May 2026 10:47:27 +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=1777891649; cv=none; b=YpZkqszLtguezUdbLE5Z4j2dwU20UaKsVB8oQOvvpHUVSvtDa8OJAQ6TicIyzquPPRJtj6b6LZ5uSux1lHcFiMXpGHYBfxYU/HzDnxEQO5JvtVoKJ7ClINCQbd7Gk5naX3ZdT2qgIEcuyod7h0SBtL72VSN5ynAYnx4uuC7lelw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777891649; c=relaxed/simple; bh=wlFRlmGUGOfX8guQV8d3MX86WvI0POQHkYy3nPAHGhE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M/ixFLR8AXIonf3+Pj2DPkCxcQnapzmiXdqeQH84bXrSbH8UBLChc1yWNxOTa5EhNirzzEneeEsSXxvbjOQOJuyXKVxxGSYPdnm/AEX8bRi01SBsPVrgoQtNVELI4bJjik9Wgy3RNW6+mjH/pZ8E82VyW+kZSWEq81sSL8gBItI= 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=t1vUzzRN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ae3s2eDh; 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="t1vUzzRN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ae3s2eDh" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777891646; 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=gi/NB0RzMU01umq9jbneD18kObEOz0PBPLV85YFGFSs=; b=t1vUzzRNhhdv/uJjEYg6r1iM/33AD47oxHsi1wsEhS4SKuxZo2ntFFcBkrfcEY6OSCtqNn GtVyL8HN5eRW5lY7d9aZTMqkRNf4VolgFGkVgAVSMqT9ubtmUnS33j4CvEbw/BOY+rhAuO wvtT9aZkIk2gyU8aPeQ3pY8g+9EJhvzz0OEBMbISchYG6g5ab0y49LVY8Px9jH+qTb+Bq9 2b3CQ2LBwCN6I59NwwO8TsxkxMRyZs39/3SBliOwjYkTGT2J0Wq8BuH+oUy6iw7RzQW2bb hbTYuNAuPrvBm9J9+zecM46JRUammuALspD71RqOgEw8ayXXGW5h4u5rX2MgYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777891646; 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=gi/NB0RzMU01umq9jbneD18kObEOz0PBPLV85YFGFSs=; b=ae3s2eDhZ6VTxvBE3Y8V9dDM1NWni0zc1DbWshQOZjSYoP7Jn/zZbtQpHClHDLS2dXiE4v dWV9yDE6wYz6jbDg== Date: Mon, 04 May 2026 12:47:19 +0200 Subject: [PATCH v2 3/4] 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: <20260504-restricted-pointers-final-v2-3-4934933503e5@linutronix.de> References: <20260504-restricted-pointers-final-v2-0-4934933503e5@linutronix.de> In-Reply-To: <20260504-restricted-pointers-final-v2-0-4934933503e5@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=1777891643; l=1956; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=wlFRlmGUGOfX8guQV8d3MX86WvI0POQHkYy3nPAHGhE=; b=xMLfHdB/dtcBgLUUTP2biYXBLF+0NbBbjF6bMLH7pW7fJWPAqIfehFiJM9+Lmqvt2rTRF55XH sE8cWRsGWUOAHz5e+S2GQvvoQRtAUFD2IC1u6heXMJfCp6+UNNo7R0w 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. 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 --- lib/vsprintf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 9f359b31c8d1..021db95087fe 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -862,6 +863,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); + + guard(lock_map_acquire)(&vsprintf_restricted_pointer_map); + switch (kptr_restrict) { case 0: /* Handle as %p, hash and do _not_ leak addresses. */ --=20 2.53.0 From nobody Sun Jun 14 02:33:01 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 44B193A63F1 for ; Mon, 4 May 2026 10:47:28 +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=1777891649; cv=none; b=iaTEPoN59lh1apI9DyJ+lPeibM68lBwOXlhmxQjFxLM6uKtRZZnqD4vj5uSOcStfwrbNLiS6G1H+VVonhE+6+yOpHnBCKnFCYV3moTde142XQKiYlP9kUaRkm5LQQOxfkMANkT5VGjfd3detCZF6IeE8OefSN+4HCpsPfnx1kSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777891649; c=relaxed/simple; bh=cj79tgC3dkANYQMvHafzxPjuPZeqLTCTo6zJRjFZft8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bt3xoWnk7slMc280U+NoTVB+xT5hE/pu8YxeJTw5S6W106okCjWkS8bmIMD1foOtfn2Vv4dAv/eDj3Nca1ta4latFcvxFGQvYmQvJ1O4dXNqyJnh4dmo1U+lLdWeiFLf7MwKxQDdZHZRqy+IZZb93EaLq4DvshHrhbHMu5pNNcY= 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=j3G2QgYL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CQbWOhdq; 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="j3G2QgYL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CQbWOhdq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777891646; 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=PsCdOkpXxchXq5yCTTtYRm+AzOj71Uwa8aetkv2LHYI=; b=j3G2QgYLH9ExCoeXEU4KYtm3YzNRfTIePziO1saRv5d2s/xxkAbQee55Ut6siX+jxO5RhW Rqv8UNyZ7RFj3XDCQEc1bSp3z73gPYPnEatHXFgKBf0rGPZRRrLtrhFve1KvETGOkTEpqA C09xLz8IhKIjf8dwtqJFGV59rPwVChGZFDKt9ZZuedyzBsILJXLyi3E4CNRHJye0kaWSpc 3qXcLI0A2ufgG3uuO3gH3g8IP7rd6fT9alLBLPYKSFcASBqJCQoXcKmK8WSkWmbhCGyou6 WvH/750EWBISDuOQ3O+egy/eNvigJ5p0zdEOXhATka/Ga7vZRfntQxkFuRcYHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777891646; 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=PsCdOkpXxchXq5yCTTtYRm+AzOj71Uwa8aetkv2LHYI=; b=CQbWOhdqcMlbWyktsjOMp8oIVoBo0LRYKHMwX2xdHaRHcWfzqdGmnTkdFMWWdjrAWA9LHU q1x+gEtvCiEjd4Cg== Date: Mon, 04 May 2026 12:47:20 +0200 Subject: [PATCH v2 4/4] 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: <20260504-restricted-pointers-final-v2-4-4934933503e5@linutronix.de> References: <20260504-restricted-pointers-final-v2-0-4934933503e5@linutronix.de> In-Reply-To: <20260504-restricted-pointers-final-v2-0-4934933503e5@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=1777891643; l=976; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=cj79tgC3dkANYQMvHafzxPjuPZeqLTCTo6zJRjFZft8=; b=M49gSKlUWVacnKb3VA9478HZQJl71SOqmRbyaMl4E7NthDiuQsfI5jb3ykU3KAhRHeBePE+CG Jja/DCtDJWoBzLq1mbrHnmCLC4X966trTyvMIFuU0rB0cX+V6ZrbLmd X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= When kptr_restrict is set to '1' restricted pointers can not be used in IRQ context. As kptr_restrict can change at any time at runtime, this means that restricted pointers can not be used from IRQ context in general. Add some assertions to detect misuse early, independently of the runtime configuration of the test system. Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vsprintf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 021db95087fe..185bd9e61144 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -871,6 +871,10 @@ char *restricted_pointer(char *buf, char *end, const v= oid *ptr, =20 guard(lock_map_acquire)(&vsprintf_restricted_pointer_map); =20 + lockdep_assert(!in_hardirq()); + lockdep_assert(!in_serving_softirq()); + lockdep_assert(!in_nmi()); + switch (kptr_restrict) { case 0: /* Handle as %p, hash and do _not_ leak addresses. */ --=20 2.53.0