mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	tracing: Verify if trace array exists before destroying it.
A trace array can be destroyed from userspace or kernel. Verify if the trace array exists before proceeding to destroy/remove it. Link: http://lkml.kernel.org/r/1565805327-579-3-git-send-email-divya.indi@oracle.com Reviewed-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> Signed-off-by: Divya Indi <divya.indi@oracle.com> [ Removed unneeded braces ] Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
		
							parent
							
								
									2d6425af61
								
							
						
					
					
						commit
						e585e6469d
					
				
					 2 changed files with 17 additions and 4 deletions
				
			
		| 
						 | 
					@ -3728,7 +3728,6 @@ static int complete_formation(struct module *mod, struct load_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	module_enable_ro(mod, false);
 | 
						module_enable_ro(mod, false);
 | 
				
			||||||
	module_enable_nx(mod);
 | 
						module_enable_nx(mod);
 | 
				
			||||||
	module_enable_x(mod);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Mark state as coming so strong_try_module_get() ignores us,
 | 
						/* Mark state as coming so strong_try_module_get() ignores us,
 | 
				
			||||||
	 * but kallsyms etc. can see us. */
 | 
						 * but kallsyms etc. can see us. */
 | 
				
			||||||
| 
						 | 
					@ -3751,6 +3750,11 @@ static int prepare_coming_module(struct module *mod)
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Make module executable after ftrace is enabled */
 | 
				
			||||||
 | 
						mutex_lock(&module_mutex);
 | 
				
			||||||
 | 
						module_enable_x(mod);
 | 
				
			||||||
 | 
						mutex_unlock(&module_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	blocking_notifier_call_chain(&module_notify_list,
 | 
						blocking_notifier_call_chain(&module_notify_list,
 | 
				
			||||||
				     MODULE_STATE_COMING, mod);
 | 
									     MODULE_STATE_COMING, mod);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8556,17 +8556,26 @@ static int __remove_instance(struct trace_array *tr)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int trace_array_destroy(struct trace_array *tr)
 | 
					int trace_array_destroy(struct trace_array *this_tr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct trace_array *tr;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!tr)
 | 
						if (!this_tr)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mutex_lock(&event_mutex);
 | 
						mutex_lock(&event_mutex);
 | 
				
			||||||
	mutex_lock(&trace_types_lock);
 | 
						mutex_lock(&trace_types_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = __remove_instance(tr);
 | 
						ret = -ENODEV;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Making sure trace array exists before destroying it. */
 | 
				
			||||||
 | 
						list_for_each_entry(tr, &ftrace_trace_arrays, list) {
 | 
				
			||||||
 | 
							if (tr == this_tr) {
 | 
				
			||||||
 | 
								ret = __remove_instance(tr);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mutex_unlock(&trace_types_lock);
 | 
						mutex_unlock(&trace_types_lock);
 | 
				
			||||||
	mutex_unlock(&event_mutex);
 | 
						mutex_unlock(&event_mutex);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue