Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b28271a4 authored by Tze-nan Wu's avatar Tze-nan Wu Committed by Vegard Nossum
Browse files

tracing: Fix overflow in get_free_elt()



commit bcf86c01ca4676316557dd482c8416ece8c2e143 upstream.

"tracing_map->next_elt" in get_free_elt() is at risk of overflowing.

Once it overflows, new elements can still be inserted into the tracing_map
even though the maximum number of elements (`max_elts`) has been reached.
Continuing to insert elements after the overflow could result in the
tracing_map containing "tracing_map->max_size" elements, leaving no empty
entries.
If any attempt is made to insert an element into a full tracing_map using
`__tracing_map_insert()`, it will cause an infinite loop with preemption
disabled, leading to a CPU hang problem.

Fix this by preventing any further increments to "tracing_map->next_elt"
once it reaches "tracing_map->max_elt".

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 08d43a5f ("tracing: Add lock-free tracing_map")
Co-developed-by: default avatarCheng-Jui Wang <cheng-jui.wang@mediatek.com>
Link: https://lore.kernel.org/20240805055922.6277-1-Tze-nan.Wu@mediatek.com


Signed-off-by: default avatarCheng-Jui Wang <cheng-jui.wang@mediatek.com>
Signed-off-by: default avatarTze-nan Wu <Tze-nan.Wu@mediatek.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 302ceb625d7b990db205a15e371f9a71238de91c)
[Vegard: s/atomic_fetch_add_unless/__atomic_add_unless/ due to missing
 commit bfc18e389c7a09fbbbed6bf4032396685b14246e ("atomics/treewide:
 Rename __atomic_add_unless() => atomic_fetch_add_unless()".]
Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
parent bd9bfbcc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment