Skip to contentSkip to conversation

ftrace: don't call kaslr_offset()

PATCH In review Arnd Bergmann 2 participants 2 messages Feb 25, 2025

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

PATCH 1/1 ftrace: don't call kaslr_offset()

From: Arnd Bergmann <[email protected]>

The kaslr_offset() function is only defined on architectures that implement CONFIG_RANDOMIZE_BASE, which leads to a build failure on 32-bit arm and likely others.

Hide the function call behind an #ifdef.

Fixes ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")

---
There is probably a nicer way to do this, this version was the minimum fix I found to unbreak the build.

---
 kernel/trace/ftrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/ftrace.c +3 -1
index ac55b97aa540..f41245716e0b 100644
@@ -7018,7 +7018,7 @@ static int ftrace_process_locs(struct module *mod,
 	unsigned long count;
 	unsigned long *p;
 	unsigned long addr;
-	unsigned long kaslr;
+	unsigned long kaslr = 0;
 	unsigned long flags = 0; /* Shut up gcc */
 	unsigned long pages;
 	int ret = -ENOMEM;
@@ -7070,8 +7070,10 @@ static int ftrace_process_locs(struct module *mod,
 		ftrace_pages->next = start_pg;
 	}
 
+#ifdef CONFIG_RANDOMIZE_BASE
 	/* For zeroed locations that were shifted for core kernel */
 	kaslr = !mod ? kaslr_offset() : 0;
+#endif
 
 	p = start;
 	pg = start_pg;
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 6 lines · On Tue, 25 Feb 2025 10:00:58 +0100 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

The kaslr_offset() function is only defined on architectures that implement CONFIG_RANDOMIZE_BASE, which leads to a build failure on 32-bit arm and likely others.

Quoted 7 lines

Hide the function call behind an #ifdef.

Fixes ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")

---
There is probably a nicer way to do this, this version was the minimum fix I found to unbreak the build.

Yep, I ended up removing the reference to kasrl_offset() altogether.

You are Cc'd on the new patch set.

Thanks,

-- Steve

Quoted 3 lines
---
 kernel/trace/ftrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)