summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/exported-sql-viewer.py
diff options
context:
space:
mode:
authorGuo Zihao <guozh23@xiaopeng.com>2026-09-22 15:53:27 +0800
committerHans Verkuil <hverkuil+cisco@kernel.org>2026-09-23 14:54:50 +0200
commita9765e3e1dfab45718f5014e2d9ce96d4070f0ca (patch)
treed7ea4aa238232be468886172cbb905a216406eae /tools/perf/scripts/python/exported-sql-viewer.py
parent760e3b055c501ba3b99626846851339d88558b6a (diff)
media: cx18: clamp bytesused in the single buffer MDL path
cx18_mdl_update_bufs_for_cpu() copies mdl->bytesused straight into the buffer when the MDL holds a single buffer: if (list_is_singular(&mdl->buf_list)) { buf = list_first_entry(&mdl->buf_list, struct cx18_buffer, list); buf->bytesused = mdl->bytesused; The value originates from the firmware. cx18_queue_get_mdl() receives it as its bytesused argument and stores it in ret->bytesused; the mailbox handler calls it as cx18_queue_get_mdl(s, id, mdl_ack->data_used), so data_used from the firmware ACK is what ends up in the buffer. Firmware that reports more than the buffer holds leaves bytesused above s->buf_size, and two paths then use it as a bound over a buffer of that size. cx18_buf_swap() walks the buffer in 32 bit words up to bytesused and byteswaps them in place: for (i = 0; i < buf->bytesused; i += 4) swab32s((u32 *)(buf->buf + i)); That writes past the end of buf->buf. The call comes from cx18_mdl_swap() for MPG streams when CX18_F_M_NEED_SWAP is set, which cx18_queue_get_mdl() does for every type except TS. cx18_copy_buf_to_user() computes the remaining length the same way: size_t len = buf->bytesused - buf->readpos; and copies it to userspace. Here len is capped at the count the reader asked for, so the read is bounded by the read() size, but it still starts from a bytesused that reaches past the buffer. The multi buffer path already guards this: _cx18_mdl_update_bufs_for_cpu() clamps each buffer to s->buf_size before assigning. Apply the same clamp in the single buffer case. The single buffer path is the common one here, not a corner case: cx18_stream_init() sets bufs_per_mdl to 1, so list_is_singular() is normally true. No Fixes tag. Both paths were introduced together with the driver (1c1e45d17b66, "V4L/DVB (7786): cx18: new driver for the Conexant CX23418 MPEG"), and the clamp in the multi buffer path was added later, leaving this one behind. Reviewed-by: Liu Chao <liuc63@xiaopeng.com> Assisted-by: LLM Signed-off-by: Guo Zihao <guozh23@xiaopeng.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
0 files changed, 0 insertions, 0 deletions