From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A23326A08F for ; Fri, 16 Jan 2026 17:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768583224; cv=none; b=hIbCGm2zAKzhhuOGnvlTM8NM7XPa7LT0UqDJsKBSPyl/vc1ulb9qHdKI3uAiuOVD2USoHiTwj8C+Q3SCeVjhQFq/1psoxjN7VXssdWxcEkmZ2BBbtp9T/4z2K9I/VnC/Hct/znzQhQFR3cF9WTDzjYC4W7k9EM0gGB2r3dOWGJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768583224; c=relaxed/simple; bh=rteIiCj5dBuWFfZKLIEfjB2yFdXAlP1LLFP7xsZnRjs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EJtURMtY5dROv3TNYu4U/ZVOKhXCr3gwXvQ28DIUway0drupQ/y3Fwy0MVwT3grGFg/xwB9g+88uo+kDuw+7OjOEn2ncaPPLY3vBw6Mxufi4nzItU5S+rKraHHC+tZh69lIPeg6pGBd6QWEBlCj0Am5NptTatTiq1R7TEsiBjTU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=A+KlCjnr; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="A+KlCjnr" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-47ee974e230so20726415e9.2 for ; Fri, 16 Jan 2026 09:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768583221; x=1769188021; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=DgsH8m8RmFOgNBfFQUhItwX/bKN2Q3Na92NMGB5I8yg=; b=A+KlCjnrLPXZl5pn+CG/km11bIrJpAFwU6AqloUVu5QttSmOIFsMOa9WcggilyeSrj Nc3YSRGLBDa90tavQgFxnsNdbWcOCqEkCd8FdIcdRG00fDesHFFgEBPtZFL+OEcAQJYg wy+I75wkPfGWd3OoCCPkq8tPtn2HC+m4xoINuBXxqm5ermAG8V4mX9e15K1nLQe4JwUy NaztkKXBI8ditZJgMhMhW2dKZkIqvxnRmgnIVgX5Tvf/nK1VK8MApzFfiOZFsJyJMzNs OLkVwpQDMB+DyFTzYzs+ZKUwKawxDn0qKcl7lZpsGGZqotRMXKvcGAZ1HY+owWXeZCJT RI3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768583221; x=1769188021; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DgsH8m8RmFOgNBfFQUhItwX/bKN2Q3Na92NMGB5I8yg=; b=D7LFk0Rq4lka+lK72QVKXZoI2CEv8OTk6VyJigoNGMSV1BRfpOuDtv/Y49kvd/GuHc Kse0p88TBlmU+CLHv3AlfV3zIWugy28M/8VztAOG2zLh9C/WqBetk6Pm4mJhJuyg7Jlu HFMipkXlE3lYnYcaCZq5uX0H82CFjntjSjCZr3S/XJU2Ae7+oEvdlNIQPmPmtrcvS6xH Sjk8M/1V/PbAmyGHjFzKG9eofZl7rKimiQMUKVZF7tuQgQqQAEhjWRMgp41iuU40G3uY 28UV5egy4J9LDNlteZrhfMpzpvy7qS8BFY0jArYTEySwT+L1oliSoEC5MhbAeS1wR1Z5 Hlgg== X-Forwarded-Encrypted: i=1; AJvYcCVxsbQpl5AIm3lsGKABJDXAXEC0X7YtVcbL8wMU/Qb1wF5KHUzISTPS/nqQmKGGXLlVky4xn4iy0BfFfis=@vger.kernel.org X-Gm-Message-State: AOJu0YyDMmtnUyh2fsj/zXMOeP3vQnVPaU+Seed40pTqJpSsW7rr/OoQ 9YO5gtMcxMCxysnPbGQ8KCPe28rei4qjNWjESK6FHnadorI2B+MNRNdgGeh9YFpZx38= X-Gm-Gg: AY/fxX4dy8x/EL+ldiX2Mh4PRA7YGV0PR4LrvLIgE8Ry66WJ5xr/1B2kDjJLovR0wPC BFLIPfsIhz9tvYwZV3VeHBhoYx1TEAwHwbiS09WXk6MGPub+sb6f9L4owc+NFfeXKlnxZb+rT8y fqOqxp1P8rS6tXAiqsmeHc99PFQv3ajTYgZ0IncTniHkLb5znJFgCQ4+ZAPclYawjsN4pu9+bXm TbaZBT8cHfibS/Eupvl4YFrxUeZ/1Yk1BWr2m6KJnQl3mfSkK1w+PXBAmpVCvguyN1Cer62K2SG pGiynu9J6UbpV0QGGn1hSLK3K3mfZ9M+chkt7afJiVLhjFnumpKjCzSUgojuLiFeM/glcGHr/0o nWAY/47vf8kWlJQBurbAQB6lyCOGYz0Lbxuz+fYiYVImAZ7p9/PL36Z/Er8z4AUpOm4Qyq3JYLj ypf+P2M9Q5yJlQaFzKy+9TuDOT X-Received: by 2002:a05:600c:5285:b0:45d:d97c:236c with SMTP id 5b1f17b1804b1-4801e33c1e1mr40672445e9.21.1768583221362; Fri, 16 Jan 2026 09:07:01 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47f428acae8sm107943535e9.4.2026.01.16.09.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jan 2026 09:07:00 -0800 (PST) Date: Fri, 16 Jan 2026 18:06:59 +0100 From: Petr Mladek To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vsprintf: Add test for restricted kernel pointers Message-ID: References: <20260114-restricted-pointers-kunit-test-v1-1-a9d8a49c6b6f@linutronix.de> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260114-restricted-pointers-kunit-test-v1-1-a9d8a49c6b6f@linutronix.de> On Wed 2026-01-14 08:27:34, Thomas Weißschuh wrote: > 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. I think that we could export "kptr_restrict" like we did with no_hash_pointers. AFAIK, it has been exported just because of the test module as well. > Please note that changes to the kptr_restrict sysctl from the kernel > commandline are only applied *after* the boot-time KUnit tests run. This is another motivation to export the symbol. Otherwise, it is really hard to test the non-default variants. BTW: I have recently heard about EXPORT_SYMBOL_NS(). It would allow to export the symbol only for some specific modules. I am not sure how exactly it works. I wonder if there already exists a namespace for KUnit tests. It would be nice to use it, even for "no_hash_pointers"... > --- 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); Hmm, the behavior of %pK depends on capabilities of the caller. The above code would work when the test is built in. But we might need to check the capabilities when using test module. If I get it correctly, the module loaded requires CAP_SYS_MODULE while %pK behavior depends on CAP_SYSLOG... > + break; > + case 2: > + default: > + test(ZEROS "00000000", "%pK", PTR); > + break; > + } > } > > static void Anyway, thanks for working on this. Best Regards, Petr