Thread (10 messages) 10 messages, 2 authors, 2025-02-06

Re: [PATCH] ftrace: Avoid potential division by zero in function_stat_show()

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-02-05 14:49:43
Also in: lkml

On Wed,  5 Feb 2025 14:21:54 +0300
Nikolay Kuratov [off-list ref] wrote:
Oops, this still does not fix an overflow because of
quoted
rec->time_square_sum += calltime * calltime;  
We can't eliminate overflows easily without both using u64 and converting
ns to us prior to any squaring. I will send an appropriate patch later
if needed. Maybe we're a way too paranoid about overflows and really want
only not to divide by zero?
Well, the divide by zero will cause a kernel crash (very bad!) whereas the
overflow just causes corrupted data (sorta bad).

But yeah, I've noticed a lot of bogus data in the stddev and pretty much
ignore it. Perhaps it would have been better not to add it to begin with :-p

The divide by zero scenario definitely needs to be fixed, and I may take my
last patch to fix it as it also stops some of the overflows.

But we can add another patch to stop the other overflows with some runtime
checks too.

-- Steve
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help