linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: ftrace: don't dereference a probably invalid address
@ 2021-06-07  3:23 Mark-PK Tsai
  2021-06-07 13:55 ` Steven Rostedt
  0 siblings, 1 reply; 8+ messages in thread
From: Mark-PK Tsai @ 2021-06-07  3:23 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, Catalin Marinas, Will Deacon, Matthias Brugger,
	linux-arm-kernel, linux-kernel, linux-mediatek, mark-pk.tsai,
	yj.chiang

Address in __mcount_loc may be invalid if somthing goes wrong.
On our arm64 platform, the bug in recordmcount make kernel
crash in ftrace_init().

https://lore.kernel.org/lkml/20210607023839.26387-1-mark-pk.tsai@mediatek.com/

Return -EFAULT if we are dealing with out-of-range condition
to prevent dereference the invalid address in ftrace_bug(),
then the kernel can disable ftrace safely for problematic
__mcount_loc.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 arch/arm64/kernel/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index b5d3ddaf69d9..98bec8445a58 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -201,7 +201,7 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
 			preempt_enable();
 
 			if (WARN_ON(!mod))
-				return -EINVAL;
+				return -EFAULT;
 		}
 
 		/*
-- 
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-08  1:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  3:23 [PATCH] arm64: ftrace: don't dereference a probably invalid address Mark-PK Tsai
2021-06-07 13:55 ` Steven Rostedt
2021-06-07 14:15   ` Mark-PK Tsai
2021-06-07 14:36     ` Mark-PK Tsai
2021-06-07 14:52     ` Steven Rostedt
2021-06-07 18:14       ` Mark-PK Tsai
2021-06-07 18:50         ` Steven Rostedt
2021-06-08  0:52           ` Mark-PK Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).