Unverified Commit ab81c301 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12433 v2 Fix CVE-2022-49006

Merge Pull Request from: @ci-robot 
 
PR sync from: Zheng Yejian <zhengyejian1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/KMOJXEBKZMEKNI5II5UYYMYKJUF6CJ7Q/ 
v1 -> v2:
- Update bugzilla link in commit message

Steven Rostedt (Google) (2):
  tracing: Add tracing_reset_all_online_cpus_unlocked() function
  tracing: Free buffers when a used dynamic event is removed


-- 
2.25.1
 
https://gitee.com/src-openeuler/kernel/issues/IAZNMK 
 
Link:https://gitee.com/openeuler/kernel/pulls/12433

 

Reviewed-by: default avatarYe Weihua <yeweihua4@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents a96aad7b 9aa1e848
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -2173,10 +2173,12 @@ void tracing_reset_online_cpus(struct array_buffer *buf)
}

/* Must have trace_types_lock held */
void tracing_reset_all_online_cpus(void)
void tracing_reset_all_online_cpus_unlocked(void)
{
	struct trace_array *tr;

	lockdep_assert_held(&trace_types_lock);

	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
		if (!tr->clear_trace)
			continue;
@@ -2188,6 +2190,13 @@ void tracing_reset_all_online_cpus(void)
	}
}

void tracing_reset_all_online_cpus(void)
{
	mutex_lock(&trace_types_lock);
	tracing_reset_all_online_cpus_unlocked();
	mutex_unlock(&trace_types_lock);
}

/*
 * The tgid_map array maps from pid to tgid; i.e. the value stored at index i
 * is the tgid last observed corresponding to pid=i.
+1 −0
Original line number Diff line number Diff line
@@ -733,6 +733,7 @@ int tracing_is_enabled(void);
void tracing_reset_online_cpus(struct array_buffer *buf);
void tracing_reset_current(int cpu);
void tracing_reset_all_online_cpus(void);
void tracing_reset_all_online_cpus_unlocked(void);
int tracing_open_generic(struct inode *inode, struct file *filp);
int tracing_open_generic_tr(struct inode *inode, struct file *filp);
int tracing_open_file_tr(struct inode *inode, struct file *filp);
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type)
		if (ret)
			break;
	}
	tracing_reset_all_online_cpus();
	mutex_unlock(&event_mutex);

	return ret;
@@ -165,6 +166,7 @@ int dyn_events_release_all(struct dyn_event_operations *type)
			break;
	}
out:
	tracing_reset_all_online_cpus();
	mutex_unlock(&event_mutex);

	return ret;
+11 −2
Original line number Diff line number Diff line
@@ -2584,7 +2584,10 @@ static int probe_remove_event_call(struct trace_event_call *call)
		 * TRACE_REG_UNREGISTER.
		 */
		if (file->flags & EVENT_FILE_FL_ENABLED)
			return -EBUSY;
			goto busy;

		if (file->flags & EVENT_FILE_FL_WAS_ENABLED)
			tr->clear_trace = true;
		/*
		 * The do_for_each_event_file_safe() is
		 * a double loop. After finding the call for this
@@ -2597,6 +2600,12 @@ static int probe_remove_event_call(struct trace_event_call *call)
	__trace_remove_event_call(call);

	return 0;
 busy:
	/* No need to clear the trace now */
	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
		tr->clear_trace = false;
	}
	return -EBUSY;
}

/* Remove an event_call */
@@ -2664,7 +2673,7 @@ static void trace_module_remove_events(struct module *mod)
	 * over from this module may be passed to the new module events and
	 * unexpected results may occur.
	 */
	tracing_reset_all_online_cpus();
	tracing_reset_all_online_cpus_unlocked();
}

static int trace_module_notify(struct notifier_block *self,
+0 −2
Original line number Diff line number Diff line
@@ -1364,7 +1364,6 @@ int synth_event_delete(const char *event_name)
	mutex_unlock(&event_mutex);

	if (mod) {
		mutex_lock(&trace_types_lock);
		/*
		 * It is safest to reset the ring buffer if the module
		 * being unloaded registered any events that were
@@ -1376,7 +1375,6 @@ int synth_event_delete(const char *event_name)
		 * occur.
		 */
		tracing_reset_all_online_cpus();
		mutex_unlock(&trace_types_lock);
	}

	return ret;