linux/include/media
Hans Verkuil 2fc11536cf V4L/DVB: videobuf-dma-sg: set correct size in last sg element
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>
2010-09-27 22:22:01 -03:00
..
davinci V4L/DVB: V4L: vpfe_capture: Add call back function for interrupt clear for vpfe_cfg 2010-05-18 00:52:43 -03:00
adv7343.h
ak881x.h V4L/DVB: V4L: v4l2-subdev driver for AK8813 and AK8814 TV-encoders from AKM 2010-05-19 12:58:02 -03:00
bt819.h
cs53l32a.h
cs5345.h
cx2341x.h V4L/DVB: cx2341x: convert to the control framework 2010-08-08 23:43:05 -03:00
cx25840.h V4L/DVB: cx25840/ivtv: replace ugly priv control with s_config 2010-08-08 23:43:05 -03:00
i2c-addr.h
ir-common.h V4L/DVB: ir-common: remove keymap tables from the module 2010-05-19 12:56:51 -03:00
ir-core.h V4L/DVB: IR: extend interfaces to support more device settings 2010-08-08 23:43:00 -03:00
ir-kbd-i2c.h V4L/DVB: ir-core: partially convert ir-kbd-i2c.c to not use ir-functions.c 2010-08-02 14:53:59 -03:00
lirc_dev.h V4L/DVB: IR/lirc: make lirc userspace and staging modules buildable 2010-08-02 16:42:55 -03:00
lirc.h V4L/DVB: IR: extend interfaces to support more device settings 2010-08-08 23:43:00 -03:00
m52790.h
msp3400.h
mt9t112.h V4L/DVB (13670): soc-camera: Add mt9t112 camera driver 2009-12-16 09:27:41 -02:00
ov772x.h soc-camera: ov772x: Modify buswidth control 2010-02-26 15:11:00 -03:00
ovcamchip.h
pwc-ioctl.h
radio-si4713.h
rc-map.h V4L/DVB: staging/lirc: port lirc_streamzap to ir-core 2010-08-08 23:42:58 -03:00
rds.h
rj54n1cb0c.h V4L/DVB (13661): rj54n1cb0c: Add cropping, auto white balance, restrict sizes, add platform data 2009-12-16 09:27:30 -02:00
saa6752hs.h
saa7115.h
saa7127.h
saa7146_vv.h V4L/DVB: saa7146: fix regression of the av7110/budget-av driver 2010-05-06 19:20:50 -03:00
saa7146.h
sh_mobile_ceu.h V4L/DVB: V4L2: sh_mobile_camera_ceu: add support for CSI2 2010-08-02 16:43:40 -03:00
sh_mobile_csi2.h V4L/DVB: V4L2: soc-camera: add a MIPI CSI-2 driver for SH-Mobile platforms 2010-08-02 16:43:39 -03:00
sh_vou.h V4L/DVB: V4L: SuperH Video Output Unit (VOU) driver 2010-05-19 12:58:01 -03:00
si4713.h
soc_camera_platform.h V4L/DVB (13659): soc-camera: convert to the new mediabus API 2009-12-16 09:27:29 -02:00
soc_camera.h V4L/DVB: V4L2: soc-camera: export soc-camera bus type for notifications 2010-08-02 16:43:38 -03:00
soc_mediabus.h V4L/DVB (13658): v4l: add a media-bus API for configuring v4l2 subdev pixel and frame formats 2009-12-16 09:27:27 -02:00
timb_radio.h V4L/DVB: radio: Add radio-timb 2010-02-26 15:10:56 -03:00
tuner-types.h
tuner.h V4L/DVB: tuner: Add a definition for the Philips FQ1236 MK5 NTSC tuner 2010-07-08 16:49:53 -03:00
tvaudio.h
tveeprom.h
tvp514x.h
tvp5150.h
tvp7002.h V4L/DVB: Definitions for TVP7002 in DM365 2010-02-26 15:11:01 -03:00
tw9910.h tw9910: use TABs for indentation 2010-02-26 15:10:59 -03:00
upd64031a.h
upd64083.h
v4l2-chip-ident.h V4L/DVB: V4L: v4l2-subdev driver for AK8813 and AK8814 TV-encoders from AKM 2010-05-19 12:58:02 -03:00
v4l2-common.h V4L/DVB: v4l2-common: simplify prio utility functions 2010-05-19 12:58:54 -03:00
v4l2-ctrls.h V4L/DVB: v4l2: Add new control handling framework 2010-08-08 23:43:03 -03:00
v4l2-dev.h V4L/DVB: v4l2: Add new control handling framework 2010-08-08 23:43:03 -03:00
v4l2-device.h V4L/DVB: v4l2: Add new control handling framework 2010-08-08 23:43:03 -03:00
v4l2-event.h V4L/DVB: V4L: Events: Add backend 2010-05-19 12:58:06 -03:00
v4l2-fh.h V4L/DVB: V4L: Events: Add backend 2010-05-19 12:58:06 -03:00
v4l2-i2c-drv.h
v4l2-int-device.h
v4l2-ioctl.h V4L/DVB: V4L: Events: Support event handling in do_ioctl 2010-05-19 12:58:07 -03:00
v4l2-mediabus.h V4L/DVB: V4L2: mediabus: add 12-bit Bayer and YUV420 pixel formats 2010-08-02 16:43:37 -03:00
v4l2-mem2mem.h V4L/DVB: add memory-to-memory device helper framework for videobuf 2010-05-19 12:58:03 -03:00
v4l2-subdev.h V4L/DVB: v4l2: Add new control handling framework 2010-08-08 23:43:03 -03:00
videobuf-core.h V4L/DVB: videobuf: Remove videobuf_mapping start and end fields 2010-08-02 15:23:09 -03:00
videobuf-dma-contig.h V4L/DVB (13377): make struct videobuf_queue_ops constant 2009-12-05 18:41:35 -02:00
videobuf-dma-sg.h V4L/DVB: videobuf-dma-sg: set correct size in last sg element 2010-09-27 22:22:01 -03:00
videobuf-dvb.h V4L/DVB (13103): create a standard method for dvb adapter drivers to override frontend ioctls 2009-12-05 18:40:21 -02:00
videobuf-vmalloc.h V4L/DVB: videobuf: Rename vmalloc fields to vaddr 2010-08-02 15:25:57 -03:00
wm8775.h