From nobody Mon Feb 9 03:13:50 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 D28BA35FF70 for ; Wed, 14 Jan 2026 07:27: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=1768375674; cv=none; b=nyjfNeCTUtiPsLyS1A36Bcb1c6ke7KuQzOmV50REjHJagroOvIOi2sGywQsEfx4cbba1p1yI51Q1KU/yCHisl/EvuV8P5KVVpxRaxlRyid19f78BG1wA6iQ2jN139su1ntH2z+G/rdjTwxnS/RBNrS7fZTmq/DvCc7UlrE2PU1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768375674; c=relaxed/simple; bh=RymK9P48XfaNke9+PnngrX7ckilihYTTC8Y9tjELYVI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=g4P15GM+C1llFcmxKuzSce6wP5olmDG+yaslcGNcNhwRpe0gFOy4tXhRIF9gtWidhnMXsWRNRUngof9i9mKSfXC2kAMMeYzMT13DsfzVwPvLEUm4sjkogZkUOFP031ogaB1kBZg9+IXTLlG65UNa+78fKnLTz6uPfdBofs0eCmg= 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=PZGIUZrs; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=azgdatcu; 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="PZGIUZrs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="azgdatcu" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1768375666; 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=5dwzBLRoXnYtVqIz+/9aDA7MXAneuyAO+oKrgHMFl3I=; b=PZGIUZrsMA19yErhuYvSWiG64PcDz7TO3pNSJxX/4TBxeiuU0+DLMld5/fAi7fkAJ/LFAD /m7IQuR1TIAcxAXf68ThzFNtkYQCea0N29CDYjsWEogtYO5Ec4p/MRD8bkXotCNRLm6d7W Sl6g2AtGic2ecbX3Q/E4p/R7Nl29/FWY3gQVhbc31Kog/033mnD1RNV+LyigfjCqcVlZqo laiKi9T7K0pkBKCjQPyygg7jtezSmfdRC9rdvcy3fg0XTTf/kF20TTeWHgobFVmT2wRRRm 8RYI7/nEgznvzuBLVbvUzD7ucNAMVv/6BDbbiJTQA4JEp4Uxv626XlyRvaLDcw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1768375666; 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=5dwzBLRoXnYtVqIz+/9aDA7MXAneuyAO+oKrgHMFl3I=; b=azgdatcuDBrEHLZFPP2efyibAzMHfXgySyNH+6LZ43V70DQ2nQPVWxW3cyo/FCPX1R18o+ +kDgQQj3JreHdFBg== Date: Wed, 14 Jan 2026 08:27:34 +0100 Subject: [PATCH] vsprintf: Add test for restricted kernel pointers 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: <20260114-restricted-pointers-kunit-test-v1-1-a9d8a49c6b6f@linutronix.de> X-B4-Tracking: v=1; b=H4sIAGVFZ2kC/x2NwQrCMBAFf6Xs2YW0iKb+inioyYsuhbTsrlIo/ XeDx2FgZieDCoxu3U6Kr5gstUF/6ii9p/oCS25MQxguoQ8jK8xVkiPzukh1qPH8qeLszXApZ6Q Yr8+UI7XIqiiy/Qf3x3H8APDkcIVwAAAA X-Change-ID: 20260109-restricted-pointers-kunit-test-ff4ec887bcd8 To: 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=1768375665; l=1634; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=RymK9P48XfaNke9+PnngrX7ckilihYTTC8Y9tjELYVI=; b=/hVt3N7Gb8OouTxLScpDxdQB79BkdoKdV2Vs/T8IofJaudpAgf9hXS0MF6h/y6bXhLPu7iFwX tlGACq6JassDIG7+1QkYx/0VuxNky+cVsGMJI2eKrKJl6A1FXuDnT3N X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Fill out the tests for restricted kernel pointers, using the %pK format. This test can only be executed when built into the kernel, as modules do not have access to the kptr_restrict knob. Signed-off-by: Thomas Wei=C3=9Fschuh --- Please note that changes to the kptr_restrict sysctl from the kernel commandline are only applied *after* the boot-time KUnit tests run. --- lib/tests/printf_kunit.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c index 7617e5b8b02c..af15d2ab4046 100644 --- a/lib/tests/printf_kunit.c +++ b/lib/tests/printf_kunit.c @@ -316,7 +316,31 @@ symbol_ptr(struct kunit *kunittest) static void kernel_ptr(struct kunit *kunittest) { - /* We can't test this without access to kptr_restrict. */ +#ifdef MODULE + kunit_skip(kunittest, "cannot access kptr_restrict from test module"); + return; +#endif + + switch (kptr_restrict) { + case 0: + if (no_hash_pointers) { + test(PTR_STR, "%pK", PTR); + } else { + char buf[PLAIN_BUF_SIZE]; + + plain_hash_to_buffer(kunittest, PTR, buf, PLAIN_BUF_SIZE); + /* %pK behaves the same as hashing */ + test(buf, "%pK", PTR); + } + break; + case 1: + test(PTR_STR, "%pK", PTR); + break; + case 2: + default: + test(ZEROS "00000000", "%pK", PTR); + break; + } } =20 static void --- base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 change-id: 20260109-restricted-pointers-kunit-test-ff4ec887bcd8 Best regards, --=20 Thomas Wei=C3=9Fschuh