linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ye Bin <yebin@huaweicloud.com>
To: rostedt@goodmis.org, mhiramat@kernel.org,
	mathieu.desnoyers@efficios.com, mark.rutland@arm.com,
	linux-trace-kernel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, yebin10@huawei.com
Subject: [PATCH 2/2] ftrace: don't allocate  ftrace module map
Date: Fri, 23 May 2025 16:39:45 +0800	[thread overview]
Message-ID: <20250523083945.3390587-3-yebin@huaweicloud.com> (raw)
In-Reply-To: <20250523083945.3390587-1-yebin@huaweicloud.com>

From: Ye Bin <yebin10@huawei.com>

If the ftrace is disabled, it is meaningless to allocate  module map.
So add check in ftrace_free_mem().

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 kernel/trace/ftrace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index ff5d9d73a4a7..56adf45de92e 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7824,6 +7824,11 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)
 
 	mutex_lock(&ftrace_lock);
 
+	if (ftrace_disabled || (mod && !mod->num_ftrace_callsites)) {
+		mutex_unlock(&ftrace_lock);
+		return;
+	}
+
 	/*
 	 * If we are freeing module init memory, then check if
 	 * any tracer is active. If so, we need to save a mapping of
-- 
2.34.1


  parent reply	other threads:[~2025-05-23  8:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  8:39 [PATCH 0/2] fix UAF when lookup kallsym after ftrace disabled Ye Bin
2025-05-23  8:39 ` [PATCH 1/2] ftrace: " Ye Bin
2025-05-23 17:54   ` Steven Rostedt
2025-05-26  1:33     ` yebin
2025-05-27 13:41       ` Steven Rostedt
2025-05-28 13:22         ` yebin
2025-05-28 14:13           ` Steven Rostedt
2025-05-23  8:39 ` Ye Bin [this message]
2025-05-24  1:13   ` [PATCH 2/2] ftrace: don't allocate ftrace module map kernel test robot

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=20250523083945.3390587-3-yebin@huaweicloud.com \
    --to=yebin@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=yebin10@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).