Skip to contentSkip to conversation

lib/vsprintf: Make no_hash_pointers take effect early

PATCH Superseded Kaitao Cheng 2 participants 4 messages Jun 10 – Jun 11

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/vsprintf: Make no_hash_pointers take effect early

From: Kaitao Cheng <[email protected]>

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.

---
 lib/vsprintf.c | 1 +
 1 file changed, 1 insertion(+)
lib/vsprintf.c +1 -0
index 4221e95701f9..9d35c84f6c49 100644
@@ -2361,6 +2361,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;
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Quoted 5 lines · Kaitao Cheng

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.

Quoted 8 lines

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.

How is it documented now? And if not documented at all, needs to be.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Kaitao Cheng

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.

Quoted 6 lines
Quoted 4 lines

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.

How is it documented now? And if not documented at all, needs to be.

In Documentation/admin-guide/kernel-parameters.txt, the descriptions of both no_hash_pointers and hash_pointers= are already marked as [KNL,EARLY], which should match the current semantics.

Signature · 2 lines
Thanks
Kaitao Cheng
#3 lore raw
Quoted 17 lines · Kaitao Cheng
Quoted 16 lines · Andy Shevchenko
Quoted 13 lines · Kaitao Cheng

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.

Quoted 5 lines
Quoted 1 line

How is it documented now? And if not documented at all, needs to be.

In Documentation/admin-guide/kernel-parameters.txt, the descriptions of both no_hash_pointers and hash_pointers= are already marked as [KNL,EARLY], which should match the current semantics.

This detail should be also mentioned in the commit message.

Signature · 2 lines
With Best Regards,
Andy Shevchenko