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] [thread-next>] [day] [month] [year] [list]
Message-ID: <e3eea04f-7240-b659-c294-b657fcef4b06@huaweicloud.com>
Date: Mon, 26 Aug 2024 10:55:58 +0800
From: Zheng Yejian <zhengyejian@...weicloud.com>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: rostedt@...dmis.org, mathieu.desnoyers@...icios.com,
 linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing: Mitigate possible softlockup in __tracing_open()

On 2024/8/25 23:05, Masami Hiramatsu (Google) wrote:
> On Sat, 24 Aug 2024 11:03:43 +0800
> Zheng Yejian <zhengyejian@...weicloud.com> wrote:
> 
>> In __tracing_open(), when max latency tracers took place on the cpu,
>> the time start of its buffer would be updated, then event entries with
>> timestamps being earlier than start of the buffer would be skipped
>> (see tracing_iter_reset()).
>>
>> Softlockup will occur if the kernel is non-preemptible and too many
>> entries were skipped in the loop that reset every cpu buffer, so add
>> cond_resched() to avoid it.
>>
>> Signed-off-by: Zheng Yejian <zhengyejian@...weicloud.com>
>> ---
>>   kernel/trace/trace.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index ebe7ce2f5f4a..88faa95b457b 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -4706,6 +4706,15 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
>>   		for_each_tracing_cpu(cpu) {
>>   			ring_buffer_read_start(iter->buffer_iter[cpu]);
>>   			tracing_iter_reset(iter, cpu);
>> +			/*
>> +			 * When max latency tracers took place on the cpu, the time start
>> +			 * of its buffer would be updated, then event entries with timestamps
>> +			 * being earlier than start of the buffer would be skipped
>> +			 * (see tracing_iter_reset()). Softlockup will occur if the kernel
>> +			 * is non-preemptible and too many entries were skipped in the loop,
>> +			 * so add cond_resched() to mitigate it.
>> +			 */
>> +			cond_resched();
> 
> OK, but why we cond_resched() only here? Another tracing_iter_reset() in
> s_start() does not cause the soft lockups in the same situation?
> 

Sorry for the late reply.

__tracing_open() is called when trace file is being opened,
s_start() is called when trace file is being read. Normally,
we read immediately after open at which tracing_iter_reset() was
just called, softlockup may be not that easily triggered in
s_start(), do we need cond_resched() there?



> Thank you,
> 
> 
>>   		}
>>   	} else {
>>   		cpu = iter->cpu_file;
>> -- 
>> 2.25.1
>>
>>
> 
> 

-- 
Thanks,
Zheng Yejian


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ