lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250528034712.138701-16-dongml2@chinatelecom.cn>
Date: Wed, 28 May 2025 11:47:02 +0800
From: Menglong Dong <menglong8.dong@...il.com>
To: alexei.starovoitov@...il.com,
	rostedt@...dmis.org,
	jolsa@...nel.org
Cc: bpf@...r.kernel.org,
	Menglong Dong <dongml2@...natelecom.cn>,
	linux-kernel@...r.kernel.org
Subject: [PATCH bpf-next 15/25] ftrace: factor out __unregister_ftrace_direct

Factor out __unregister_ftrace_direct, which doesn't hold the direct_mutex
lock.

Signed-off-by: Menglong Dong <dongml2@...natelecom.cn>
---
 kernel/trace/ftrace.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 0befb4c93e89..5b6b74ea4c20 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -113,6 +113,8 @@ bool ftrace_pids_enabled(struct ftrace_ops *ops)
 }
 
 static void ftrace_update_trampoline(struct ftrace_ops *ops);
+static int __unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+				      bool free_filters);
 
 /*
  * ftrace_disabled is set when an anomaly is discovered.
@@ -6046,8 +6048,8 @@ EXPORT_SYMBOL_GPL(register_ftrace_direct);
  *  0 on success
  *  -EINVAL - The @ops object was not properly registered.
  */
-int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
-			     bool free_filters)
+static int __unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+				      bool free_filters)
 {
 	struct ftrace_hash *hash = ops->func_hash->filter_hash;
 	int err;
@@ -6057,10 +6059,8 @@ int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
 	if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
 		return -EINVAL;
 
-	mutex_lock(&direct_mutex);
 	err = unregister_ftrace_function(ops);
 	remove_direct_functions_hash(hash, addr);
-	mutex_unlock(&direct_mutex);
 
 	/* cleanup for possible another register call */
 	ops->func = NULL;
@@ -6070,6 +6070,18 @@ int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
 		ftrace_free_filter(ops);
 	return err;
 }
+
+int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+			     bool free_filters)
+{
+	int err;
+
+	mutex_lock(&direct_mutex);
+	err = __unregister_ftrace_direct(ops, addr, free_filters);
+	mutex_unlock(&direct_mutex);
+
+	return err;
+}
 EXPORT_SYMBOL_GPL(unregister_ftrace_direct);
 
 static int
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ