mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-22 17:33:01 +00:00
2fc11536cf
This fixes a nasty memory corruption bug when using userptr I/O. The function videobuf_pages_to_sg() sets up the scatter-gather list for the DMA transfer to the userspace pages. The first transfer is setup correctly (the size is set to PAGE_SIZE - offset), but all other transfers have size PAGE_SIZE. This is wrong for the last transfer which may be less than PAGE_SIZE. Most, if not all, drivers will program the boards DMA engine correctly, i.e. even though the size in the last sg element is wrong, they will do their own size calculations and make sure the right amount is DMA-ed, and so seemingly prevent memory corruption. However, behind the scenes the dynamic DMA mapping support (in lib/swiotlb.c) may create bounce buffers if the memory pages are not in DMA-able memory. This happens for example on a 64-bit linux with a board that only supports 32-bit DMA. These bounce buffers DO use the information in the sg list to determine the size. So while the DMA engine transfers the correct amount of data, when the data is 'bounced' back too much is copied, causing buffer overwrites. The fix is simple: calculate and set the correct size for the last sg list element. Signed-off-by: Hans Verkuil <hans.verkuil@tandberg.com> Cc: stable@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> |
||
---|---|---|
.. | ||
davinci | ||
adv7343.h | ||
ak881x.h | ||
bt819.h | ||
cs53l32a.h | ||
cs5345.h | ||
cx2341x.h | ||
cx25840.h | ||
i2c-addr.h | ||
ir-common.h | ||
ir-core.h | ||
ir-kbd-i2c.h | ||
lirc_dev.h | ||
lirc.h | ||
m52790.h | ||
msp3400.h | ||
mt9t112.h | ||
ov772x.h | ||
ovcamchip.h | ||
pwc-ioctl.h | ||
radio-si4713.h | ||
rc-map.h | ||
rds.h | ||
rj54n1cb0c.h | ||
saa6752hs.h | ||
saa7115.h | ||
saa7127.h | ||
saa7146_vv.h | ||
saa7146.h | ||
sh_mobile_ceu.h | ||
sh_mobile_csi2.h | ||
sh_vou.h | ||
si4713.h | ||
soc_camera_platform.h | ||
soc_camera.h | ||
soc_mediabus.h | ||
timb_radio.h | ||
tuner-types.h | ||
tuner.h | ||
tvaudio.h | ||
tveeprom.h | ||
tvp514x.h | ||
tvp5150.h | ||
tvp7002.h | ||
tw9910.h | ||
upd64031a.h | ||
upd64083.h | ||
v4l2-chip-ident.h | ||
v4l2-common.h | ||
v4l2-ctrls.h | ||
v4l2-dev.h | ||
v4l2-device.h | ||
v4l2-event.h | ||
v4l2-fh.h | ||
v4l2-i2c-drv.h | ||
v4l2-int-device.h | ||
v4l2-ioctl.h | ||
v4l2-mediabus.h | ||
v4l2-mem2mem.h | ||
v4l2-subdev.h | ||
videobuf-core.h | ||
videobuf-dma-contig.h | ||
videobuf-dma-sg.h | ||
videobuf-dvb.h | ||
videobuf-vmalloc.h | ||
wm8775.h |