Skip to content

Commit 1362697

Browse files
committed
kconfig_has_kaslr: drop CONFIG_RELOCATABLE requirement
CONFIG_RELOCATABLE does not exist on s390x (or arm64, riscv64, etc.). Requiring it caused proc-config and boot-config to falsely signal KASLR disabled on those arches, suppressing legitimate proc-kallsyms results via the inject_kaslr_defaults tiebreak. On x86/x86_64, CONFIG_RANDOMIZE_BASE depends on CONFIG_RELOCATABLE anyway, so checking CONFIG_RANDOMIZE_BASE alone is equivalent everywhere.
1 parent 62d43ad commit 1362697

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/components/boot-config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ static unsigned long get_kernel_addr_boot_config(FILE *fp) {
7575
if (kconfig_has_kaslr(fp))
7676
return 0;
7777

78-
printf("[.] Kernel appears to have been compiled without both "
79-
"CONFIG_RELOCATABLE and CONFIG_RANDOMIZE_BASE\n");
78+
printf(
79+
"[.] Kernel appears to have been compiled without CONFIG_RANDOMIZE_BASE"
80+
" (KASLR not compiled in)\n");
8081

8182
return (unsigned long)KERNEL_TEXT_DEFAULT;
8283
}

src/components/proc-config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ static unsigned long get_kernel_addr_proc_config(FILE *fp) {
116116
if (kconfig_has_kaslr(fp))
117117
return 0;
118118

119-
printf("[.] Kernel appears to have been compiled without both "
120-
"CONFIG_RELOCATABLE and CONFIG_RANDOMIZE_BASE\n");
119+
printf(
120+
"[.] Kernel appears to have been compiled without CONFIG_RANDOMIZE_BASE"
121+
" (KASLR not compiled in)\n");
121122

122123
return (unsigned long)KERNEL_TEXT_DEFAULT;
123124
}

src/include/kconfig.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ static unsigned long get_kconfig_page_offset(FILE *fp) {
7676
}
7777

7878
/* Check if the kernel was compiled with KASLR support
79-
* (CONFIG_RELOCATABLE=y and CONFIG_RANDOMIZE_BASE=y).
80-
* Returns 1 if KASLR is enabled, 0 otherwise. */
79+
* (CONFIG_RANDOMIZE_BASE=y).
80+
*
81+
* On x86/x86_64, CONFIG_RANDOMIZE_BASE has CONFIG_RELOCATABLE as a hard
82+
* Kconfig dependency, so checking CONFIG_RANDOMIZE_BASE alone is sufficient.
83+
* On all other arches (arm64, s390x, riscv64, powerpc, mips, ...) there is
84+
* no CONFIG_RELOCATABLE; KASLR requires only CONFIG_RANDOMIZE_BASE.
85+
*
86+
* Returns 1 if KASLR is compiled in, 0 otherwise. */
8187
static int kconfig_has_kaslr(FILE *fp) {
82-
return is_kconfig_set(fp, "CONFIG_RELOCATABLE") &&
83-
is_kconfig_set(fp, "CONFIG_RANDOMIZE_BASE");
88+
return is_kconfig_set(fp, "CONFIG_RANDOMIZE_BASE");
8489
}
8590

8691
#endif /* KASLD_KCONFIG_H */

0 commit comments

Comments
 (0)