From nobody Mon May 25 00:08:05 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 C5C763C0619 for ; Wed, 20 May 2026 08:40:24 +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=1779266426; cv=none; b=c6QLiiQVNIy3M2dGEa9NENhUhz6uZd/HjuAzmJVy84OXHQASxd5OypdOu31XwtFHLN2UALPs1o+P5XUUUjNJk4sYd6Dmm+140xF7oF4QpIzQT1qY0ZRuYCZbHybS1ToZoFz2b52txnIRm98etjs7G6MmR99Jla9S7Up1lIlYK+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266426; c=relaxed/simple; bh=AkYj5AHtrC/uF53D3aGzzwsC2RGoqU7NdyGliCiAltE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ho28M719yU9Zp2bXblnjAMAMKjxPw4jIhJXnSM/OuRcjg5yoW3/MsSrxEfifzoZLAUDW4lEoRx7/ezewWbNX8Nlk82woo6+dIssWBJuOsWjeDDZhg1fEzgAC1B4jRX06EBduQYfX4IDlS2AlPitUiaN/a3T/zPXh1WmgN0SEzcA= 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=SpTCledQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vXNAu2vq; 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="SpTCledQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vXNAu2vq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266423; 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=SpTCledQPSNqgpt0IAKW0WgQq1Xqc7iTLmcItrpYiQizNimSRfeX90J1cAe4+g/clCNZsZ z5IriZAqyhkDdISxO5bD4i4zJhZlBQWgXI51IDz5FeNXws4Q7kw40oB+pbCEaIVou4HLqa QgLAwM/p2sB70HfOASjw+GXHobNWl7nk0qpfs5SAKTqLgxWkNVgM9F58kszDgo/RybsHw1 T3hvPIiPjMQqZlHi7DCB3+FKfG+VLsDTfpDLgC9Mz9H61C8dxmuVjTvKlNCUExT78tMwEZ z5nNTinJce5Fb9gBtAxEePEd1FXB+DSopiad4kByFbPwDsybRxL/sbrLL3lYTw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266423; 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=vXNAu2vqa03VGTZ5XO39BdyqlQTofKD8PpnONLnnBbGZKXwaD1N/KWLKNz9FXLyahQIXdg UBGgkx+42jDDVzDw== Date: Wed, 20 May 2026 10:40:00 +0200 Subject: [PATCH v3 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: <20260520-restricted-pointers-final-v3-1-76bca6a6ab3f@linutronix.de> References: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@linutronix.de> In-Reply-To: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@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=1779266417; l=1669; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=AkYj5AHtrC/uF53D3aGzzwsC2RGoqU7NdyGliCiAltE=; b=ZZd4eW/N9bVO5CEuqJhhmpoRiJIqfe7z/snFE1Fw84CB9a/+Mgin2by1lBUvxRBUEnNT+fTor UUxm9juAGh3DFcdWkXY/ZZPhz18Z9KOAbEuxxlebEKf3UIOqNtLwwQy 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 Mon May 25 00:08:05 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 54A0C3C197E for ; Wed, 20 May 2026 08:40:25 +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=1779266426; cv=none; b=hn1c5tchYNkW59vtPSObST419ccKjinjMSZb2kZpHK+c8fS5rjK44CJ89eKXlq3ksqcEsWEwbFfBKPNstD6qDbekMLDVS+Ns4Gec6liudbzf8/9MHFaFzZj/vriocHT+tFXQdQ6bzXtr3vJcDbgb9dBrFTykBK3f9tCNU3EdGqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266426; c=relaxed/simple; bh=VTtSmlTf4DOzDvKpDdSuJkdCtmRx26UF3OdVKOsA+MI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dZrNb1Ga97EZ8I6xtWbW6Cs2ZoM6fgLLrw/VhjhnJ56gOrQ5h+q6OpNbbciSVakxdF24f3kJya8MS2jW8P2Y/tknzkEN+E3+D1mUErb8cddb18yDbGwb1q6Pzwbhy8/YWxKMpG14SB21JWiq5OVfi+jOwaMzp7X2IL+nucJNv8Q= 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=oG8it2Jh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UhJUZcJc; 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="oG8it2Jh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UhJUZcJc" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266423; 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=oG8it2JhA1Wr1GFe7bbI7JACFf41uX1T7MlTtV9RqT9WJ7gOD+2BqPUbnKjveG32/KwuJF QQXgeNctsluMMJEpitYSobNrvqjGwG4T1UlEIR64/jWxRAa/a1eYvzF+RO5jv6v+S6s1cQ TJVnz301nG9e7An2fICf5IdBDySx7IjAtcSa8Yd58axo2+9e63gR6sRa11E3mpXlQ2J7eW rAs5nmqTfFzYn60APVpEYk/8GjAxpzRgb6rledwHKIJT6W5tJUa4dG8hjpEv+kKntvlrOq t50+GUhJhhPAaZBgbbPyl5isqhAe0Dj/Alv8xzWwKP3HRIa2cIhIgFmpzUyc9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266423; 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=UhJUZcJc3Q2EZgAIpcPW0LoAR1c8Dunt+jlyMy3n8lP7qJPZCzusQ4hKODX58hdC2fVta4 +medufYJChEbfMDA== Date: Wed, 20 May 2026 10:40:01 +0200 Subject: [PATCH v3 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: <20260520-restricted-pointers-final-v3-2-76bca6a6ab3f@linutronix.de> References: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@linutronix.de> In-Reply-To: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@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=1779266417; l=938; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=VTtSmlTf4DOzDvKpDdSuJkdCtmRx26UF3OdVKOsA+MI=; b=cWh9+pY28Z60+qr0jSuhJLelOyj+P5+ATvEQkcsde0wAUgIo3yFX6COytSj3K33zccOKjreF7 crgL9QXuI7QDtFaO2h2LvoCHChaZsoKSztflKXjk227LbeOmkB2Eph9 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 Mon May 25 00:08:05 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 E66D33C1984 for ; Wed, 20 May 2026 08:40:25 +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=1779266427; cv=none; b=HsNDBObdF1/Pw4Lz2SIH3+TS8MAQ4vIw7KCaMjDR0L6Z0VfYYzEEqSmL/WtORehniJYakIltNeDGfeAUFcdhK5o0qSPLlQNbhWlmGYR+tRcDciQBgeqXnKbPVrD9c58jWiNit8TxEYPOycEMZeoAHereqh/LstWNxJ52ACZQElM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266427; c=relaxed/simple; bh=/mEXOiC/f6xskRob+7ts6LDI/fxACCuuHHDi9u7W/iQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rz7/ZUZ/jhbUyP3e04NavUufUMlAtsRdzUPe1vSwqLb6s4vQ5gakGYs+G833O3ukoIJ8+YOpW0HnYyhROjpADM1pr7+Gu/EBPEfTQ4fmp+UpLFqvUcNELgiKxLlWLRsD9fjORKv0kQJ2Xmo5w2/pme5ldZE7ZLnWKYKhOBGe9dk= 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=tPrpXX9v; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Bm6JCFl9; 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="tPrpXX9v"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Bm6JCFl9" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266424; 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=EgxoQN7k7B/yedJeRoNxR5qGWcfMv24tVRYYH6yjonk=; b=tPrpXX9vBAksPlu8bWYvspoJ0ClDTdowVDjAuWkGeCx7IHRPWzKQavACdqVxfuknKBSu0H lfXMNZDkB8gxKM6bX3sO4ydAl05U1aihPIt18VLPJKsymvc/3g1MOEfnGkLE/mMYXPohP0 rfVZE587gE0et3eecBSqDOnZaAA0FqMx0I0Yk3HAedfd6wI0ih7JL89qjRhjGvVJ1h4WfR pRVq5zrWv+nTtSaTB09FHsSWVXtry6QW6fUblgr27yGfPH1YqvsjbhbyiWgwp1qVbvNQTm 3ed2QQenmHckTrx+D3LWNSInnrUtt0fgsyHkakkgE4HflCVqYlvhxG0/QykBlw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266424; 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=EgxoQN7k7B/yedJeRoNxR5qGWcfMv24tVRYYH6yjonk=; b=Bm6JCFl9h9/DvbDXvN4EgL8mo0qv7dl3cJbeZWM/6wgNW1zQ1ZqzwmwLHAL5EoGnUs9Jh0 pUO/YBtAGJZvRHDA== Date: Wed, 20 May 2026 10:40:02 +0200 Subject: [PATCH v3 3/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: <20260520-restricted-pointers-final-v3-3-76bca6a6ab3f@linutronix.de> References: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@linutronix.de> In-Reply-To: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@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=1779266417; l=1956; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=/mEXOiC/f6xskRob+7ts6LDI/fxACCuuHHDi9u7W/iQ=; b=GvmuWGO4VY15wjtkfuIezHgqzhSdrEb0bUEASOcqVLsm9QlVJ3GqQ7vq4bK2GZOl9OWQX8LeD MHZYSNqMm1eAmBl+Wyz5Q2Pgw84KeQDZB74eVFXAdyHKkk2kVbKkR2Z 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.54.0 From nobody Mon May 25 00:08:05 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 74B243C2761 for ; Wed, 20 May 2026 08:40: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=1779266427; cv=none; b=U8FB3nW//JoXm2Y3UxynAjYX6D8pyxG6ob5Ot38ObYoEPEay4/t2p8RSEsQjk1547dpdSGIKkyuPGriE0a6sd1sTgmDdHcq71wN6hxvTastSZBJZJMppkQ7gC0MaBNw5yQLVfO6+GBgyH2aTC1SMUGbc/sURQr9nfiV8zfCSR1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266427; c=relaxed/simple; bh=crtE/8KNOzfZF9Y3J+8u7c/EVSRwssDdjCjXNLyIIho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L5bJuosESMkI0HVyNAebNDGQQcxl7PTSZGv7MQ0lXK/8YlBrgCzvTthZOWTi+qyN/wYgi5EaegaKStkwe81GZw7NfhIdOb1XJqSsf3JZPI1h8ij7ueGnK0PfovFOIJ/qthUzQC/z5QlaHM9zn+gHoqyRf9iz/zo5oczlpsewp/A= 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=SLebhuAM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KTQl6S3v; 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="SLebhuAM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KTQl6S3v" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266425; 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=NI3p6jPnca9YK1N0ePo0tzZy+m5ojwRnX88v2Fh2DMc=; b=SLebhuAMsckSdX7QPaOtAMhVJy0jXyBgc6cY6A2HO9cJSJ6j9Q8ZO+c9/qnu/vy71latbM TOLIO1z726J/hrox0MkhYx0FOMF0fTjUFFoHQoyXXwyvbb/d27GP+auak8V+pfXx4XMiMA FspEjzxjT5dZTa7XkGU/A+hpp8O+NuNmGtQY/wQTm8O2yBNI3z5JqFenu72VK7zJTRPaeD 982yDH0u5BpjgBSzTlUXqfW4FywVX0rAGJ9pHb1mPcmvDOt996XECYMUu1q4bbkBAcoKGf /nE6QRYYTztf/dTLHd57WlxV2rdpu3n907Wawl76CNJnYwP3Sm7+ldtF/Fsdbg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266425; 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=NI3p6jPnca9YK1N0ePo0tzZy+m5ojwRnX88v2Fh2DMc=; b=KTQl6S3v/XzfrDEEhJMLxaWEgwtaEgj588uufKn4CsWMWCjQBoiSS6h7mtwtN8Ch1bbhPy JOgok4T/so7AGaDg== Date: Wed, 20 May 2026 10:40:03 +0200 Subject: [PATCH v3 4/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: <20260520-restricted-pointers-final-v3-4-76bca6a6ab3f@linutronix.de> References: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@linutronix.de> In-Reply-To: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@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=1779266417; l=952; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=crtE/8KNOzfZF9Y3J+8u7c/EVSRwssDdjCjXNLyIIho=; b=zdGa9dfL4QJCxaxZyd08nnaXkrD5ClzwKelo0l3wVggxqC+QuqSfzA5hXss6obYMkR6b031nT t/zZB6T6kkBAd1s17AB6kw6HkfoTY75ljOpRTbv7+9qPHwgrAdxDYm8 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 021db95087fe..69dbd22f0e9e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -882,7 +882,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 Mon May 25 00:08:05 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 349063C3442 for ; Wed, 20 May 2026 08:40: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=1779266428; cv=none; b=O7qSGZD6OhAl95hyUNm6c7cRy6DM/iH4EpBpz5Lj2RT/FuwG/p/HW4F3JnrpNnhqfOW4xfCzPxSzAf46qX2XAtQYzCl7Pe1OIXvVUxkQIZN5PBRxP4X2SD2ppZ+8cDdNN0fH636hnF4CeMILkCDxitg5BsDoo7DQvqiSVnSQ+rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266428; c=relaxed/simple; bh=qVILxSYSWhU7taL0ecIo2aAMmiE0rBSf1uXPN8hTrzM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GkRE87dXRdWMEzYyDakMsDWxDlq9ckCj4nutnrVZDKWmgAazwMWnQPE7vGry6j5xzKleHd8y05WCVPjHfWLXYDNzBIDhAwrdt9eeBrd3Rn8GZcOxZ8bqRFsc9OwL3YBepsrfV7Fn/OEUvLltL2YjH6oGTfqSG45PtrrFHuUX5/s= 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=rcPLdIfQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HZMylKGg; 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="rcPLdIfQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HZMylKGg" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266425; 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=9KBbpSpmlfV1Uq+CO2cJL6w9JaFSW+b5NIk73Ezoxgo=; b=rcPLdIfQCuQ6NEGJYet1xiJ6CEtZYsHd6vlf3yRX+zMEmEOqVEwibUnEMrmLvirVyRqSYp uPX1iKq9S/ckXBcilPzHxln+OiA9Rlox+GZrpqFaBugh4DvUUJ3S2LYAJ4kmbFld1/gYhw ppPLSXhy27zwa3uGNqiyUsWU2p9Wy67WrtJjdFWCH2vA3tigg5c59DHn7fUKCjvJWW3Zfn XK4o4d/ocx7KB+GL4dsvmln5lyTl4qy/KDnUKhcNGxITt+ZD6CMbipjpAHE5hNtrIaD9FR jnP/Q/pIH71DIfX4EYDLSVgcBtamYirg14iOrFfxU+NLjaxZNNtFiCYQhPuEyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266425; 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=9KBbpSpmlfV1Uq+CO2cJL6w9JaFSW+b5NIk73Ezoxgo=; b=HZMylKGgI9FhxbnPUH+fuDFqNrVMfJxq4D2qaTnrWyLByrZYd59xeDi8DuteUELNZxnKOE wvb78wqYSqh+QCDg== Date: Wed, 20 May 2026 10:40:04 +0200 Subject: [PATCH v3 5/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: <20260520-restricted-pointers-final-v3-5-76bca6a6ab3f@linutronix.de> References: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@linutronix.de> In-Reply-To: <20260520-restricted-pointers-final-v3-0-76bca6a6ab3f@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=1779266417; l=897; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=qVILxSYSWhU7taL0ecIo2aAMmiE0rBSf1uXPN8hTrzM=; b=Zy8bPZOakZIDYIThK+ju4GHZ1EZJBNDZjeEcOO+Y+vMOsyDH29dyCRFBhGq5z8V5C4Dq8jIxp 5wA8FpZoxhZBM23CSqmke/bYeoLcTxR9tUjPMIleEP+MHyEwHl8jeH2 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 69dbd22f0e9e..c48a771a3ac3 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -871,6 +871,8 @@ char *restricted_pointer(char *buf, char *end, const vo= id *ptr, =20 guard(lock_map_acquire)(&vsprintf_restricted_pointer_map); =20 + lockdep_assert(in_task()); + switch (kptr_restrict) { case 0: /* Handle as %p, hash and do _not_ leak addresses. */ --=20 2.54.0