Skip to content

Commit 0d054d4

Browse files
keesPeter Zijlstra
authored andcommitted
x86/boot: Allow a "silent" kaslr random byte fetch
Under earlyprintk, each RNG call produces a debug report line. To support the future FGKASLR feature, which will fetch random bytes during function shuffling, this is not useful information (each line is identical and tells us nothing new), needlessly spamming the console. Instead, allow for a NULL "purpose" to suppress the debug reporting. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a54c401 commit 0d054d4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

arch/x86/lib/kaslr.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,32 @@ unsigned long kaslr_get_random_long(const char *purpose)
5656
unsigned long raw, random = get_boot_seed();
5757
bool use_i8254 = true;
5858

59-
debug_putstr(purpose);
60-
debug_putstr(" KASLR using");
59+
if (purpose) {
60+
debug_putstr(purpose);
61+
debug_putstr(" KASLR using");
62+
}
6163

6264
if (has_cpuflag(X86_FEATURE_RDRAND)) {
63-
debug_putstr(" RDRAND");
65+
if (purpose)
66+
debug_putstr(" RDRAND");
6467
if (rdrand_long(&raw)) {
6568
random ^= raw;
6669
use_i8254 = false;
6770
}
6871
}
6972

7073
if (has_cpuflag(X86_FEATURE_TSC)) {
71-
debug_putstr(" RDTSC");
74+
if (purpose)
75+
debug_putstr(" RDTSC");
7276
raw = rdtsc();
7377

7478
random ^= raw;
7579
use_i8254 = false;
7680
}
7781

7882
if (use_i8254) {
79-
debug_putstr(" i8254");
83+
if (purpose)
84+
debug_putstr(" i8254");
8085
random ^= i8254();
8186
}
8287

@@ -86,7 +91,8 @@ unsigned long kaslr_get_random_long(const char *purpose)
8691
: "a" (random), "rm" (mix_const));
8792
random += raw;
8893

89-
debug_putstr("...\n");
94+
if (purpose)
95+
debug_putstr("...\n");
9096

9197
return random;
9298
}

0 commit comments

Comments
 (0)