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-prev] [day] [month] [year] [list]
Message-ID: <5E951914.70104@cn.fujitsu.com>
Date:   Tue, 14 Apr 2020 09:59:48 +0800
From:   Xiao Yang <yangx.jy@...fujitsu.com>
To:     Steven Rostedt <rostedt@...dmis.org>
CC:     <mingo@...hat.com>, <linux-kernel@...r.kernel.org>,
        <linux-kselftest@...r.kernel.org>,
        <linux-trace-devel@...r.kernel.org>
Subject: Re: [PATCH] tracing: Fix the race between registering 'snapshot'
 event trigger and triggering 'snapshot' operation

On 2020/4/13 23:02, Steven Rostedt wrote:
> On Mon, 13 Apr 2020 15:12:52 +0800
> Xiao Yang<yangx.jy@...fujitsu.com>  wrote:
>
>> Traced event can trigger 'snapshot' operation(i.e. calls snapshot_trigger()
>> or snapshot_count_trigger()) when register_snapshot_trigger() has completed
>> registration but doesn't allocate spare buffer for 'snapshot' event trigger.
>> 'snapshot' operation always detects the lack of allocated buffer in the rare
>> case so make register_snapshot_trigger() allocate spare buffer first.
>>
>> trigger-snapshot.tc in kselftest reproduces the issue on slow vm:
>> -----------------------------------------------------------
>> cat trace
>> ...
>> ftracetest-3028  [002] ....   236.784290: sched_process_fork: comm=ftracetest pid=3028 child_comm=ftracetest child_pid=3036
>>       <...>-2875  [003] ....   240.460335: tracing_snapshot_instance_cond: *** SNAPSHOT NOT ALLOCATED ***
>>       <...>-2875  [003] ....   240.460338: tracing_snapshot_instance_cond: *** stopping trace here!   ***
>> -----------------------------------------------------------
>>
>> Signed-off-by: Xiao Yang<yangx.jy@...fujitsu.com>
>> ---
>>   kernel/trace/trace_events_trigger.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
>> index dd34a1b46a86..00e54cdcef3e 100644
>> --- a/kernel/trace/trace_events_trigger.c
>> +++ b/kernel/trace/trace_events_trigger.c
>> @@ -1088,9 +1088,13 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
>>   			  struct event_trigger_data *data,
>>   			  struct trace_event_file *file)
>>   {
>> -	int ret = register_trigger(glob, ops, data, file);
>> +	int alloc_ret, ret;
>>
>> -	if (ret>  0&&  tracing_alloc_snapshot_instance(file->tr) != 0) {
>> +	alloc_ret = tracing_alloc_snapshot_instance(file->tr);
>> +
>> +	ret = register_trigger(glob, ops, data, file);
>> +
>> +	if (ret>  0&&  alloc_ret != 0) {
>>   		unregister_trigger(glob, ops, data, file);
>>   		ret = 0;
>>   	}
>
>
> Why register if the allocation failed? Just switch the logic:
>
> 	int ret = tracing_alloc_snapshot_instance(file->tr);
>
> 	if (ret != 0)
> 		return 0;
>
> 	return register_trigger(glob, ops, data, file);
Hi Steve,

It looks simpler and better.
I think we can drop the unnecessary ret variable as well.

Thanks,
Xiao Yang
>
>
> -- Steve
>
>
> .
>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ