]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tracing/remotes: Fix page_va[] access before counter update in trace_remote_alloc_buf...
authorFuad Tabba <fuad.tabba@linux.dev>
Mon, 13 Jul 2026 07:28:23 +0000 (08:28 +0100)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 22 Jul 2026 20:53:29 +0000 (16:53 -0400)
commit94b83ff0c0a69e42f403b59918529fbca2a89daf
tree0e44966fea82ae4f4459c57c933b94d54a6589ad
parent1590cf0329716306e948a8fc29f1d3ee87d3989f
tracing/remotes: Fix page_va[] access before counter update in trace_remote_alloc_buffer()

page_va[] is annotated __counted_by(nr_page_va), so nr_page_va must
cover an index before that element is accessed. The allocation loop
writes page_va[id] while nr_page_va is still id and increments it only
afterwards, so every write is one element past the declared count.

The store is out of bounds with respect to the annotation: a build with
CONFIG_UBSAN_BOUNDS on a toolchain that honours __counted_by
(clang >= 20.1, gcc >= 15.1) flags it as an array-index overflow.

Increment nr_page_va before writing the element it now covers. A failed
allocation then leaves the slot counted but NULL; the error path frees
it with free_page(0), which is a no-op.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260713072823.2668323-1-fuad.tabba@linux.dev
Fixes: 96e43537af546 ("tracing: Introduce trace remotes")
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_remote.c