]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ftrace: Avoid potential division by zero in function_stat_show()
authorNikolay Kuratov <kniv@yandex-team.ru>
Thu, 6 Feb 2025 09:01:56 +0000 (12:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2025 17:25:37 +0000 (18:25 +0100)
commit746cc474a95473591853927b3a9792a2d671155b
tree86aaeec2cc184e03864e224a78282bde4ef7da41
parent435d2964af815aae456db554c62963b4515f19d0
ftrace: Avoid potential division by zero in function_stat_show()

commit a1a7eb89ca0b89dc1c326eeee2596f263291aca3 upstream.

Check whether denominator expression x * (x - 1) * 1000 mod {2^32, 2^64}
produce zero and skip stddev computation in that case.

For now don't care about rec->counter * rec->counter overflow because
rec->time * rec->time overflow will likely happen earlier.

Cc: stable@vger.kernel.org
Cc: Wen Yang <wenyang@linux.alibaba.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20250206090156.1561783-1-kniv@yandex-team.ru
Fixes: e31f7939c1c27 ("ftrace: Avoid potential division by zero in function profiler")
Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/ftrace.c