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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 21 Jun 2013 13:18:05 +0900
From:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To:	Tom Zanussi <tom.zanussi@...ux.intel.com>
Cc:	rostedt@...dmis.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 10/11] tracing: add and use generic set_trigger_filter()
 implementation

(2013/06/21 3:31), Tom Zanussi wrote:
> diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
> index 88ac7da..7c5627f 100644
> --- a/include/trace/ftrace.h
> +++ b/include/trace/ftrace.h
> @@ -522,14 +522,6 @@ ftrace_raw_event_##call(void *__data, proto)				\
>  	int __data_size;						\
>  	int pc;								\
>  									\
> -	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,			\
> -		     &ftrace_file->flags))				\
> -		event_triggers_call(ftrace_file);			\
> -									\
> -	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,			\
> -		     &ftrace_file->flags))				\
> -		return;							\
> -									\
>  	local_save_flags(irq_flags);					\
>  	pc = preempt_count();						\
>  									\
> @@ -547,8 +539,22 @@ ftrace_raw_event_##call(void *__data, proto)				\
>  									\
>  	{ assign; }							\
>  									\
> +	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,			\
> +		     &ftrace_file->flags)) {				\
> +		ring_buffer_discard_commit(buffer, event);		\
> +									\
> +		if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,		\
> +			     &ftrace_file->flags))			\
> +			event_triggers_call(ftrace_file, entry);	\
> +		return;							\
> +	}								\
> +									\
>  	if (!filter_current_check_discard(buffer, event_call, entry, event)) \
>  		trace_buffer_unlock_commit(buffer, event, irq_flags, pc); \
> +									\
> +	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,			\
> +		     &ftrace_file->flags))				\
> +		event_triggers_call(ftrace_file, entry);		\

Actually, since "entry" is a part of "event" which may be already discarded,
I think we should not access it here. It may not cause real problem because
even if it is discarded, that does NOT mean it is freed. However, it depends
on the ring-buffer implementation.

I recommend you to call event triggers before commit the event. It will also
make the code simpler :)

> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index e287011..47fa712 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -319,14 +319,6 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  	if (!sys_data)
>  		return;
>  
> -	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> -		     &sys_data->enter_file->flags))
> -		event_triggers_call(sys_data->enter_file);
> -
> -	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
> -		     &sys_data->enter_file->flags))
> -		return;
> -
>  	size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;
>  
>  	buffer = tr->trace_buffer.buffer;
> @@ -339,9 +331,23 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  	entry->nr = syscall_nr;
>  	syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);
>  
> +	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
> +		     &sys_data->enter_file->flags)) {
> +		ring_buffer_discard_commit(buffer, event);
> +
> +		if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> +			     &sys_data->enter_file->flags))
> +			event_triggers_call(sys_data->enter_file, entry);
> +		return;
> +	}
> +
>  	if (!filter_current_check_discard(buffer, sys_data->enter_event,
>  					  entry, event))
>  		trace_current_buffer_unlock_commit(buffer, event, 0, 0);
> +
> +	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> +		     &sys_data->enter_file->flags))
> +		event_triggers_call(sys_data->enter_file, entry);
>  }
>  
>  static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
> @@ -363,14 +369,6 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>  	if (!sys_data)
>  		return;
>  
> -	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> -		     &sys_data->exit_file->flags))
> -		event_triggers_call(sys_data->exit_file);
> -
> -	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
> -		     &sys_data->exit_file->flags))
> -		return;
> -
>  	buffer = tr->trace_buffer.buffer;
>  	event = trace_buffer_lock_reserve(buffer,
>  			sys_data->exit_event->event.type, sizeof(*entry), 0, 0);
> @@ -381,9 +379,23 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>  	entry->nr = syscall_nr;
>  	entry->ret = syscall_get_return_value(current, regs);
>  
> +	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
> +		     &sys_data->exit_file->flags)) {
> +		ring_buffer_discard_commit(buffer, event);
> +
> +		if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> +			     &sys_data->exit_file->flags))
> +			event_triggers_call(sys_data->exit_file, entry);
> +		return;
> +	}
> +
>  	if (!filter_current_check_discard(buffer, sys_data->exit_event,
>  					  entry, event))
>  		trace_current_buffer_unlock_commit(buffer, event, 0, 0);
> +
> +	if (test_bit(FTRACE_EVENT_FL_TRIGGER_MODE_BIT,
> +		     &sys_data->exit_file->flags))
> +		event_triggers_call(sys_data->exit_file, entry);
>  }
>  
>  static int reg_event_syscall_enter(struct ftrace_event_file *file,
> 

Same changes are needed here.

Thank you,

-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@...achi.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists