Skip to contentSkip to conversation

fix: enable early printing of hashed pointers

PATCH In review Tobin C. Harding 2 participants 9 messages Jul 10, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover fix: enable early printing of hashed pointers

Hi Ted,

Sending this set to you because it fixes the recent patch set applied to your random-next branch.

This set includes changes already posted on LKML as

[PATCH v9 0/4] enable early printing of hashed pointers

Since I'm a massive noob I did not realise that since v7 of this set was applied to random-next already that doing incremental versions was pointless.

So, this set is the changes done in v8 and v9 of the above patch set. I have retained the acked-by tag from Randy for the docs fixes. Attribution for pointing out the issues has been 'lost in translation', I'll buy you guys a beer one day instead ...

With this set applied linux-next still throws a build warning

lib/vsprintf.c:1667:13: warning: ‘have_filled_random_ptr_key’ defined but not used [-Wunused-variable]

This is fixed by another patch currently in flight ([PATCH] "vsprintf:
fix build warning" - thanks Arnd).

Epic amounts of confusion, solely caused as usual by myself.

thanks,
Tobin.

Tobin C. Harding (3):
random: Remove unnecessary cast
vsprintf: Remove incorrect EXPORT_SYMBOL
docs: Fix docs for boot parameter debug_boot_weak_hash

 Documentation/admin-guide/kernel-parameters.txt | 13 ++++++-------
 drivers/char/random.c                           |  2 +-
 lib/vsprintf.c                                  |  1 -
 3 files changed, 7 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 random: Remove unnecessary cast

Currently we are casting an argument to the macro min_t(). This is unnecessary since the macro already includes a cast.

Remove unnecessary cast from argument to macro min_t()

---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index d686aa2a129b..03bd13876901 100644
@@ -1736,7 +1736,7 @@ int __must_check get_random_bytes_arch(void *buf, int nbytes)
 	trace_get_random_bytes_arch(left, _RET_IP_);
 	while (left) {
 		unsigned long v;
-		int chunk = min_t(int, left, (int)sizeof(unsigned long));
+		int chunk = min_t(int, left, sizeof(unsigned long));
 
 		if (!arch_get_random_long(&v))
 			break;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] random: Remove unnecessary cast

Quoted 6 lines · On Tue, 10 Jul 2018 10:25:17 +1000 "Tobin C. Harding" <[email protected]> wrote:

Currently we are casting an argument to the macro min_t(). This is unnecessary since the macro already includes a cast.

Remove unnecessary cast from argument to macro min_t()

-- Steve

Quoted 17 lines
---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
index d686aa2a129b..03bd13876901 100644
@@ -1736,7 +1736,7 @@ int __must_check get_random_bytes_arch(void *buf, int nbytes)
 	trace_get_random_bytes_arch(left, _RET_IP_);
 	while (left) {
 		unsigned long v;
-		int chunk = min_t(int, left, (int)sizeof(unsigned long));
+		int chunk = min_t(int, left, sizeof(unsigned long));
 
 		if (!arch_get_random_long(&v))
 			break;
#3 lore raw

PATCH 2/3 vsprintf: Remove incorrect EXPORT_SYMBOL

In reply to Tobin C. Harding

Recently boot variable 'debug_boot_weak_hash' was added (by me). In a classic case of cargo cult programming the novice developer added a macro call to EXPORT_SYMBOL(). This is wrong and was pointed out on LKML. As pointed out EXPORT_SYMBOL() cannot be used on static variables.

Remove incorrect usage of macro EXPORT_SYMBOL()

Fixes bfe80ed3d7c76 ("vsprintf: add command line option debug_boot_weak_hash")
---
 lib/vsprintf.c | 1 -
 1 file changed, 1 deletion(-)
lib/vsprintf.c +0 -1
index cdc2c355dff5..fe834a201f3d 100644
@@ -1655,7 +1655,6 @@ static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key);
 
 /* Make pointers available for printing early in the boot sequence. */
 static int debug_boot_weak_hash __ro_after_init;
-EXPORT_SYMBOL(debug_boot_weak_hash);
 
 static int __init debug_boot_weak_hash_enable(char *str)
 {
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH 2/3] vsprintf: Remove incorrect EXPORT_SYMBOL

Quoted 10 lines · On Tue, 10 Jul 2018 10:25:18 +1000 "Tobin C. Harding" <[email protected]> wrote:

Recently boot variable 'debug_boot_weak_hash' was added (by me). In a classic case of cargo cult programming the novice developer added a macro call to EXPORT_SYMBOL(). This is wrong and was pointed out on LKML. As pointed out EXPORT_SYMBOL() cannot be used on static variables.

Remove incorrect usage of macro EXPORT_SYMBOL()

Fixes bfe80ed3d7c76 ("vsprintf: add command line option debug_boot_weak_hash")

Hmm, not sure if Ted rebases his trees or not, but if he does, he could also fold this into that commit.

-- Steve

Quoted 16 lines
---
 lib/vsprintf.c | 1 -
 1 file changed, 1 deletion(-)
lib/vsprintf.c +0 -1
index cdc2c355dff5..fe834a201f3d 100644
@@ -1655,7 +1655,6 @@ static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key);
 
 /* Make pointers available for printing early in the boot sequence. */
 static int debug_boot_weak_hash __ro_after_init;
-EXPORT_SYMBOL(debug_boot_weak_hash);
 
 static int __init debug_boot_weak_hash_enable(char *str)
 {
#5 lore raw

PATCH 3/3 docs: Fix docs for boot parameter debug_boot_weak_hash

In reply to Tobin C. Harding

Recently boot parameter 'debug_boot_weak_hash' was added. Latter discussion on LKML developed more descriptive documentation but due to the programmers lack of understanding (*cough* me) on how linux-next works these improvements never got picked up.

Update documentation for boot parameter 'debug_boot_weak_hash' as discussed (patch posted and acked) on LKML.

Fixes bfe80ed3d7c76 ("vsprintf: add command line option debug_boot_weak_hash")
---
 Documentation/admin-guide/kernel-parameters.txt | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -7
index 31c9b76058a7..e3b1c84d19c6 100644
@@ -749,13 +749,12 @@
 	debug		[KNL] Enable kernel debugging (events log level).
 
 	debug_boot_weak_hash
-			[KNL] Enable printing pointers early in the boot
-			sequence.  If enabled, we use a weak hash instead of
-			siphash to hash pointers.  Use this option if you need
-			to see pointer values during early boot (i.e you are
-			seeing instances of '(___ptrval___)').
-			Cryptographically insecure, please do not use on
-			production kernels.
+			[KNL] Enable printing [hashed] pointers early in the
+			boot sequence.  If enabled, we use a weak hash instead
+			of siphash to hash pointers.  Use this option if you are
+			seeing instances of '(___ptrval___)') and need to see a
+			value (hashed pointer) instead. Cryptographically
+			insecure, please do not use on production kernels.
 
 	debug_locks_verbose=
 			[KNL] verbose self-tests
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] docs: Fix docs for boot parameter debug_boot_weak_hash

Quoted 11 lines · On Tue, 10 Jul 2018 10:25:19 +1000 "Tobin C. Harding" <[email protected]> wrote:

Recently boot parameter 'debug_boot_weak_hash' was added. Latter discussion on LKML developed more descriptive documentation but due to the programmers lack of understanding (*cough* me) on how linux-next works these improvements never got picked up.

Update documentation for boot parameter 'debug_boot_weak_hash' as discussed (patch posted and acked) on LKML.

Fixes bfe80ed3d7c76 ("vsprintf: add command line option debug_boot_weak_hash")

-- Steve

Quoted 28 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -7
index 31c9b76058a7..e3b1c84d19c6 100644
@@ -749,13 +749,12 @@
 	debug		[KNL] Enable kernel debugging (events log level).
 
 	debug_boot_weak_hash
-			[KNL] Enable printing pointers early in the boot
-			sequence.  If enabled, we use a weak hash instead of
-			siphash to hash pointers.  Use this option if you need
-			to see pointer values during early boot (i.e you are
-			seeing instances of '(___ptrval___)').
-			Cryptographically insecure, please do not use on
-			production kernels.
+			[KNL] Enable printing [hashed] pointers early in the
+			boot sequence.  If enabled, we use a weak hash instead
+			of siphash to hash pointers.  Use this option if you are
+			seeing instances of '(___ptrval___)') and need to see a
+			value (hashed pointer) instead. Cryptographically
+			insecure, please do not use on production kernels.
 
 	debug_locks_verbose=
 			[KNL] verbose self-tests
maintainer
#7 lore raw
In reply to Tobin C. Harding
Quoted 3 lines · On Tue, 10 Jul 2018 10:25:16 +1000 "Tobin C. Harding" <[email protected]> wrote:

Since I'm a massive noob I did not realise that since v7 of this set was applied to random-next already that doing incremental versions was pointless.

I wouldn't say you are a noob anymore. You are making the same types of mistakes that seasoned kernel developers make ;-)

-- Steve

#8 lore raw
Quoted 9 lines · Steven Rostedt
Quoted 3 lines · On Tue, 10 Jul 2018 10:25:16 +1000 "Tobin C. Harding" <[email protected]> wrote:

Since I'm a massive noob I did not realise that since v7 of this set was applied to random-next already that doing incremental versions was pointless.

I wouldn't say you are a noob anymore. You are making the same types of mistakes that seasoned kernel developers make ;-)

Thanks for the vote of confidence Steve :)