mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early
@ 2026-06-18 11:06 Kaitao Cheng
  2026-06-22 12:20 ` Petr Mladek
  2026-06-25  9:57 ` Petr Mladek
  0 siblings, 2 replies; 3+ messages in thread
From: Kaitao Cheng @ 2026-06-18 11:06 UTC (permalink / raw)
  To: akpm, pmladek, rostedt, andriy.shevchenko, linux, senozhatsky
  Cc: linux-kernel, muchun.song, Kaitao Cheng

From: Kaitao Cheng <chengkaitao@kylinos.cn>

The no_hash_pointers boot parameter is now handled as an alias for
hash_pointers=never. However, hash_pointers=never only records the
selected mode during early parameter parsing, and no_hash_pointers is
not updated until hash_pointers_finalize() runs later from SLUB init.

This leaves a window during very early boot where %p output is still
hashed even though the user explicitly requested unhashed pointers with
no_hash_pointers or hash_pointers=never.

Set no_hash_pointers as soon as the "never" mode is parsed. The later
hash_pointers_finalize() call still keeps the final policy decision in
one place, but explicit requests to disable pointer hashing now take
effect for early boot users too.

Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
Changes in v3 (Petr Mladek):
- Avoid stale no_hash_pointers state when hash_pointers overrides it.

Changes in v2 (Andy Shevchenko):
- Add a description of the kernel documentation to the commit log.

Link to v2:
https://lore.kernel.org/all/20260612030642.14239-1-kaitao.cheng@linux.dev/

Link to v1:
https://lore.kernel.org/all/20260610124525.59110-1-kaitao.cheng@linux.dev/
---
 lib/vsprintf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 4221e95701f9..ca2f12144152 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2352,6 +2352,9 @@ void __init hash_pointers_finalize(bool slub_debug)
 
 static int __init hash_pointers_mode_parse(char *str)
 {
+	/* Avoid stale no_hash_pointers state when hash_pointers overrides it */
+	no_hash_pointers = false;
+
 	if (!str) {
 		pr_warn("Hash pointers mode empty; falling back to auto.\n");
 		hash_pointers_mode = HASH_PTR_AUTO;
@@ -2361,6 +2364,7 @@ static int __init hash_pointers_mode_parse(char *str)
 	} else if (strcmp(str, "never") == 0) {
 		pr_info("Hash pointers mode set to never.\n");
 		hash_pointers_mode = HASH_PTR_NEVER;
+		no_hash_pointers = true;
 	} else if (strcmp(str, "always") == 0) {
 		pr_info("Hash pointers mode set to always.\n");
 		hash_pointers_mode = HASH_PTR_ALWAYS;
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early
  2026-06-18 11:06 [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early Kaitao Cheng
@ 2026-06-22 12:20 ` Petr Mladek
  2026-06-25  9:57 ` Petr Mladek
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2026-06-22 12:20 UTC (permalink / raw)
  To: Kaitao Cheng
  Cc: akpm, rostedt, andriy.shevchenko, linux, senozhatsky,
	linux-kernel, muchun.song, Kaitao Cheng

On Thu 2026-06-18 19:06:40, Kaitao Cheng wrote:
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
> 
> The no_hash_pointers boot parameter is now handled as an alias for
> hash_pointers=never. However, hash_pointers=never only records the
> selected mode during early parameter parsing, and no_hash_pointers is
> not updated until hash_pointers_finalize() runs later from SLUB init.
> 
> This leaves a window during very early boot where %p output is still
> hashed even though the user explicitly requested unhashed pointers with
> no_hash_pointers or hash_pointers=never.
> 
> Set no_hash_pointers as soon as the "never" mode is parsed. The later
> hash_pointers_finalize() call still keeps the final policy decision in
> one place, but explicit requests to disable pointer hashing now take
> effect for early boot users too.
> 
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>

LGTM, feel free to use:

Reviewed-by: Petr Mladek <pmladek@suse.com>

I am going to queue it via printk git tree for 7.3. I have already
sent printk changes for 7.2 and this does not look serious enough to
create yet another pull request. I could still add it to a pull
request for 7.2 if a more serious fix appeared.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early
  2026-06-18 11:06 [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early Kaitao Cheng
  2026-06-22 12:20 ` Petr Mladek
@ 2026-06-25  9:57 ` Petr Mladek
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2026-06-25  9:57 UTC (permalink / raw)
  To: Kaitao Cheng
  Cc: akpm, rostedt, andriy.shevchenko, linux, senozhatsky,
	linux-kernel, muchun.song, Kaitao Cheng

On Thu 2026-06-18 19:06:40, Kaitao Cheng wrote:
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
> 
> The no_hash_pointers boot parameter is now handled as an alias for
> hash_pointers=never. However, hash_pointers=never only records the
> selected mode during early parameter parsing, and no_hash_pointers is
> not updated until hash_pointers_finalize() runs later from SLUB init.
> 
> This leaves a window during very early boot where %p output is still
> hashed even though the user explicitly requested unhashed pointers with
> no_hash_pointers or hash_pointers=never.
> 
> Set no_hash_pointers as soon as the "never" mode is parsed. The later
> hash_pointers_finalize() call still keeps the final policy decision in
> one place, but explicit requests to disable pointer hashing now take
> effect for early boot users too.
> 
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>

JFYI, the patch has been pushed into printk/linux.git,
branch for-7.3-trivial.

As the branch name suggests, it is intended for 7.3.
But as a trivial change, I could add it to a pull request for some
7.2-rcX when I need to create one because of a more important fix.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-25  9:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-18 11:06 [PATCH v3] lib/vsprintf: Make no_hash_pointers take effect early Kaitao Cheng
2026-06-22 12:20 ` Petr Mladek
2026-06-25  9:57 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome