1 From 074376ac0e1d1fcd4fafebca86ee6158e7c20680 Mon Sep 17 00:00:00 2001
2 From: Jiri Kosina <jkosina@suse.cz>
3 Date: Sat, 29 Jun 2019 23:22:33 +0200
4 Subject: ftrace/x86: Anotate text_mutex split between ftrace_arch_code_modify_post_process() and ftrace_arch_code_modify_prepare()
6 From: Jiri Kosina <jkosina@suse.cz>
8 commit 074376ac0e1d1fcd4fafebca86ee6158e7c20680 upstream.
10 ftrace_arch_code_modify_prepare() is acquiring text_mutex, while the
11 corresponding release is happening in ftrace_arch_code_modify_post_process().
13 This has already been documented in the code, but let's also make the fact
14 that this is intentional clear to the semantic analysis tools such as sparse.
16 Link: http://lkml.kernel.org/r/nycvar.YFH.7.76.1906292321170.27227@cbobk.fhfr.pm
18 Fixes: 39611265edc1a ("ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()")
19 Fixes: d5b844a2cf507 ("ftrace/x86: Remove possible deadlock between register_kprobe() and ftrace_run_update_code()")
20 Signed-off-by: Jiri Kosina <jkosina@suse.cz>
21 Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
22 Cc: Guenter Roeck <linux@roeck-us.net>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 arch/x86/kernel/ftrace.c | 2 ++
27 1 file changed, 2 insertions(+)
29 --- a/arch/x86/kernel/ftrace.c
30 +++ b/arch/x86/kernel/ftrace.c
32 #ifdef CONFIG_DYNAMIC_FTRACE
34 int ftrace_arch_code_modify_prepare(void)
35 + __acquires(&text_mutex)
37 mutex_lock(&text_mutex);
39 @@ -44,6 +45,7 @@ int ftrace_arch_code_modify_prepare(void
42 int ftrace_arch_code_modify_post_process(void)
43 + __releases(&text_mutex)
45 set_all_modules_text_ro();