From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Miroslav Benes <mbenes@suse.cz>
Subject: [for-linus][PATCH 2/8] ftrace: Free the trampoline when ftrace_startup() fails
Date: Mon, 21 Sep 2020 20:26:22 -0400 [thread overview]
Message-ID: <20200922002659.731360699@goodmis.org> (raw)
In-Reply-To: 20200922002620.231334654@goodmis.org
From: Miroslav Benes <mbenes@suse.cz>
Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
missed to remove ops from new ftrace_ops_trampoline_list in
ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
lead to BUG if such ops come from a module which may be removed.
Moreover, the trampoline itself is not freed in this case.
Fix it by calling ftrace_trampoline_free() during the rollback.
Link: https://lkml.kernel.org/r/20200831122631.28057-1-mbenes@suse.cz
Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
Fixes: f8b8be8a310a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict")
Signed-off-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 275441254bb5..656d7cb5a78c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2862,6 +2862,8 @@ int ftrace_startup(struct ftrace_ops *ops, int command)
__unregister_ftrace_function(ops);
ftrace_start_up--;
ops->flags &= ~FTRACE_OPS_FL_ENABLED;
+ if (ops->flags & FTRACE_OPS_FL_DYNAMIC)
+ ftrace_trampoline_free(ops);
return ret;
}
--
2.28.0
next prev parent reply other threads:[~2020-09-22 0:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 0:26 [for-linus][PATCH 0/8] tracing: Fixes for 5.9 Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 1/8] kprobes: Fix to check probe enabled before disarm_kprobe_ftrace() Steven Rostedt
2020-09-22 0:26 ` Steven Rostedt [this message]
2020-09-22 0:26 ` [for-linus][PATCH 3/8] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 4/8] tracing: Make the space reserved for the pid wider Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 5/8] ftrace: Let ftrace_enable_sysctl take a kernel pointer buffer Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 6/8] tracing: fix double free Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 7/8] kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot Steven Rostedt
2020-09-22 0:26 ` [for-linus][PATCH 8/8] bootconfig: init: make xbc_namebuf static Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200922002659.731360699@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox