Commit
3110d09bb98e3ac66482a7b257548a1683ec6c1a
tracing: Fix ignored return value of resize_buffer_duplicate_size()
When tr->allocated_snapshot is true, resize_buffer_duplicate_size() is
called to update the snapshot buffer size. However, its return value was
not checked. In case of a failed resize this could lead next snapshot
being incomplete.
Add resize_buffer_duplicate_size() result check and return error if
resize fails.
Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260928152634.4354-1-d.kandybka@gmail.com
Fixes: 180e4e390978 ("tracing: Add snapshot refcount")
Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Dmitry Kandybka <d.kandybka@gmail.com> · 2026-09-28 15:26 UTC · committed by Steven Rostedt
1 file changed,
+4
−1
modified kernel/trace/trace_snapshot.c
| @@ -675,9 +675,12 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 675 | 675 | if (iter->cpu_file != RING_BUFFER_ALL_CPUS) | |
| 676 | 676 | return -EINVAL; | |
| 677 | 677 | #endif | |
| 678 | - | if (tr->allocated_snapshot) | |
| 678 | + | if (tr->allocated_snapshot) { | |
| 679 | 679 | ret = resize_buffer_duplicate_size(&tr->snapshot_buffer, | |
| 680 | 680 | &tr->array_buffer, iter->cpu_file); | |
| 681 | + | if (ret < 0) | |
| 682 | + | return ret; | |
| 683 | + | } | |
| 681 | 684 | ||
| 682 | 685 | ret = tracing_arm_snapshot_locked(tr); | |
| 683 | 686 | if (ret) | |