summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/task-analyzer.py
diff options
context:
space:
mode:
authorGuo Zihao <guozh23@xiaopeng.com>2026-09-18 15:17:43 +0800
committerHans Verkuil <hverkuil+cisco@kernel.org>2026-09-23 14:54:50 +0200
commit07a721fe202f904f7b391c0675788a02ee8f1f1a (patch)
tree776814fddc3655181f9c71be75ec670b2a4cff45 /tools/perf/scripts/python/task-analyzer.py
parentf5863ea3f99265e5e297e3dcf0f47432fee2b8ac (diff)
media: saa7146: bound the page table build against its size
saa7146_pgtable_build_single() writes one entry per page of the DMA buffer into the page table, without checking that the table has room for them: ptr = pt->cpu; for_each_sg_dma_page(list, &dma_iter, sglen, 0) { *ptr++ = cpu_to_le32(sg_page_iter_dma_address(&dma_iter)); nr_pages++; } /* safety; fill the page table up with the last valid page */ fill = *(ptr-1); for (i = nr_pages; i < 1024; i++) *ptr++ = fill; The table is allocated by saa7146_pgtable_alloc(), which asks dma_alloc_coherent() for exactly PAGE_SIZE bytes and records the same size in pt->size: pt->size = PAGE_SIZE; That is 1024 __le32 entries, the number the fill loop already uses as a literal. Buffers larger than 1024 pages therefore write past the end of the coherent allocation, and the fill loop cannot compensate: by the time it runs, ptr has already moved past the end. The buffer size is reachable from userspace. vidioc_try_fmt_vid_cap() accepts any bytesperline below (2 * PAGE_SIZE * depth) / 8 and any height below the PAL/NTSC maximum, and derives sizeimage from them: if (f->fmt.pix.bytesperline > (2 * PAGE_SIZE * fmt->depth) / 8) f->fmt.pix.bytesperline = calc_bpl; f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height; With BGR32 (depth 32), bytesperline 32768 and height 576, sizeimage is 18874368 bytes, or 4608 pages. queue_setup() hands that size to vb2, so a 4608 page buffer is allocated and the page table build writes 3584 entries past its end. Reject a page table build that would not fit, and reject formats whose sizeimage cannot fit in the tables, so the format is refused at VIDIOC_S_FMT time rather than during buffer setup. No Fixes tag. The page table layout and the 1024 entry literal come from the original saa7146 driver. Reviewed-by: Liu Chao <liuc63@xiaopeng.com> Signed-off-by: Guo Zihao <guozh23@xiaopeng.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/task-analyzer.py')
0 files changed, 0 insertions, 0 deletions