Commit 4b28b68d authored by Masami Hiramatsu (Google)'s avatar Masami Hiramatsu (Google) Committed by Zheng Yejian
Browse files

tracing/trigger: Fix to return error if failed to alloc snapshot

stable inclusion
from stable-v5.10.210
commit 56cfbe60710772916a5ba092c99542332b48e870
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9HL6U
CVE: CVE-2024-26920

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=56cfbe60710772916a5ba092c99542332b48e870

--------------------------------

commit 0958b33ef5a04ed91f61cef4760ac412080c4e08 upstream.

Fix register_snapshot_trigger() to return error code if it failed to
allocate a snapshot instead of 0 (success). Unless that, it will register
snapshot trigger without an error.

Link: https://lore.kernel.org/linux-trace-kernel/170622977792.270660.2789298642759362200.stgit@devnote2



Fixes: 0bbe7f71 ("tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation")
Cc: stable@vger.kernel.org
Cc: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
parent f8ab733c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1140,8 +1140,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
			  struct event_trigger_data *data,
			  struct trace_event_file *file)
{
	if (tracing_alloc_snapshot_instance(file->tr) != 0)
		return 0;
	int ret = tracing_alloc_snapshot_instance(file->tr);

	if (ret < 0)
		return ret;

	return register_trigger(glob, ops, data, file);
}