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-next>] [day] [month] [year] [list]
Message-Id: <20220508161827.1014186-1-xiehuan09@gmail.com>
Date:   Mon,  9 May 2022 00:18:27 +0800
From:   Jeff Xie <xiehuan09@...il.com>
To:     rostedt@...dmis.org
Cc:     mingo@...hat.com, mhiramat@...nel.org, zanussi@...nel.org,
        linux-kernel@...r.kernel.org, Jeff Xie <xiehuan09@...il.com>
Subject: [PATCH] tracing: Fix possible crash in ftrace_free_ftrace_ops()

Currently if the ftrace_allocate_ftrace_ops() return -ENOMEM,
the ftrace_free_ftrace_ops() will kfree(NULL).
 
trace_array_create()
{
	...
	if (ftrace_allocate_ftrace_ops(tr) < 0)
		goto out_free_tr;
	...
out_free_tr:
        ftrace_free_ftrace_ops(tr);
	...
}

ftrace_allocate_ftrace_ops()
{
	...
	ops = kzalloc(sizeof(*ops), GFP_KERNEL);
        if (!ops)
                return -ENOMEM;
	...
}

ftrace_free_ftrace_ops()
{
        kfree(tr->ops);
        tr->ops = NULL;
}

Signed-off-by: Jeff Xie <xiehuan09@...il.com>
---
 kernel/trace/trace_functions.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 9f1bfbe105e8..d186d6101695 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -73,6 +73,9 @@ int ftrace_allocate_ftrace_ops(struct trace_array *tr)
 
 void ftrace_free_ftrace_ops(struct trace_array *tr)
 {
+	if (!tr->ops)
+		return;
+
 	kfree(tr->ops);
 	tr->ops = NULL;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ