summaryrefslogtreecommitdiff
path: root/scripts/lib/abi/helpers.py
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2025-03-13 14:16:18 +0300
committerSteven Rostedt (Google) <rostedt@goodmis.org>2025-03-28 15:39:56 +0300
commit5dbeb56bb9589e1051f6af6877cd375f3a901afb (patch)
treeb50177030a4e3c55042c88319b6c83434b71c577 /scripts/lib/abi/helpers.py
parentf00c9201f942dddb58617c881ffd4e4a1a1c49ab (diff)
downloadlinux-5dbeb56bb9589e1051f6af6877cd375f3a901afb.tar.xz
tracing: Initialize scratch_size to zero to prevent UB
In allocate_trace_buffer() the following code: buf->buffer = ring_buffer_alloc_range(size, rb_flags, 0, tr->range_addr_start, tr->range_addr_size, struct_size(tscratch, entries, 128)); tscratch = ring_buffer_meta_scratch(buf->buffer, &scratch_size); setup_trace_scratch(tr, tscratch, scratch_size); Has undefined behavior if ring_buffer_alloc_range() fails because "scratch_size" is not initialize. If the allocation fails, then buf->buffer will be NULL. The ring_buffer_meta_scratch() will return NULL immediately if it is passed a NULL buffer and it will not update scratch_size. Then setup_trace_scratch() will return immediately if tscratch is NULL. Although there's no real issue here, but it is considered undefined behavior to pass an uninitialized variable to a function as input, and UBSan may complain about it. Just initialize scratch_size to zero to make the code defined behavior and a little more robust. Link: https://lore.kernel.org/all/44c5deaa-b094-4852-90f9-52f3fb10e67a@stanley.mountain/ Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'scripts/lib/abi/helpers.py')
0 files changed, 0 insertions, 0 deletions