linux/drivers/media/pci
Gustavo A. R. Silva 8d4abca95e media: ngene: Fix out-of-bounds bug in ngene_command_config_free_buf()
Fix an 11-year old bug in ngene_command_config_free_buf() while
addressing the following warnings caught with -Warray-bounds:

arch/alpha/include/asm/string.h:22:16: warning: '__builtin_memcpy' offset [12, 16] from the object at 'com' is out of the bounds of referenced subobject 'config' with type 'unsigned char' at offset 10 [-Warray-bounds]
arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [12, 16] from the object at 'com' is out of the bounds of referenced subobject 'config' with type 'unsigned char' at offset 10 [-Warray-bounds]

The problem is that the original code is trying to copy 6 bytes of
data into a one-byte size member _config_ of the wrong structue
FW_CONFIGURE_BUFFERS, in a single call to memcpy(). This causes a
legitimate compiler warning because memcpy() overruns the length
of &com.cmd.ConfigureBuffers.config. It seems that the right
structure is FW_CONFIGURE_FREE_BUFFERS, instead, because it contains
6 more members apart from the header _hdr_. Also, the name of
the function ngene_command_config_free_buf() suggests that the actual
intention is to ConfigureFreeBuffers, instead of ConfigureBuffers
(which takes place in the function ngene_command_config_buf(), above).

Fix this by enclosing those 6 members of struct FW_CONFIGURE_FREE_BUFFERS
into new struct config, and use &com.cmd.ConfigureFreeBuffers.config as
the destination address, instead of &com.cmd.ConfigureBuffers.config,
when calling memcpy().

This also helps with the ongoing efforts to globally enable
-Warray-bounds and get us closer to being able to tighten the
FORTIFY_SOURCE routines on memcpy().

Link: https://github.com/KSPP/linux/issues/109
Fixes: dae52d009f ("V4L/DVB: ngene: Initial check-in")
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/linux-hardening/20210420001631.GA45456@embeddedor/
2021-07-19 19:33:46 -05:00
..
b2c2 media: flexcop: avoid -Wempty-body warning 2021-04-09 13:05:01 +02:00
bt8xx media: subdev: disallow ioctl for saa6588/davinci 2021-06-17 10:18:37 +02:00
cobalt media: cobalt: fix race condition in setting HPD 2021-05-19 09:51:39 +02:00
cx18 media: v4l2-subdev: add subdev-wide state struct 2021-06-17 10:01:27 +02:00
cx88 media: pci: cx88: switch from 'pci_' to 'dma_' API 2021-06-17 10:24:41 +02:00
cx23885 media: cx23885: switch from 'pci_' to 'dma_' API 2021-04-06 16:07:10 +02:00
cx25821 media updates for v5.13-rc1 2021-04-28 09:24:36 -07:00
ddbridge treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
dm1105 media: dm1105: switch from 'pci_' to 'dma_' API 2020-11-27 14:10:07 +01:00
dt3155 media: media/pci: use vb2_video_unregister_device() 2020-08-28 15:01:54 +02:00
intel media: v4l2-subdev: add subdev-wide state struct 2021-06-17 10:01:27 +02:00
ivtv media: ivtv: get rid of DVB deprecated ioctls 2021-06-04 08:06:53 +02:00
mantis media: mantis: remove orphan mantis_core.c 2021-03-22 17:27:13 +01:00
meye treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
netup_unidvb media: netup_unidvb: Don't leak SPI master in probe error path 2020-12-07 14:18:57 +00:00
ngene media: ngene: Fix out-of-bounds bug in ngene_command_config_free_buf() 2021-07-19 19:33:46 -05:00
pluto2 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
pt1 media: media/pci/pt1: Assign value when defining variables 2021-03-22 13:04:05 +01:00
pt3 media: pci: Use dev_get_drvdata where possible 2019-07-25 06:45:10 -04:00
saa7134 media: subdev: disallow ioctl for saa6588/davinci 2021-06-17 10:18:37 +02:00
saa7146 media: saa7146: fix array overflow in vidioc_s_audio() 2020-12-03 07:46:34 +01:00
saa7164 media: pci: saa7164: Rudimentary spelling fixes in the file saa7164-types.h 2021-03-22 11:57:37 +01:00
smipcie media: smipcie: fix interrupt handling and IR timeout 2021-02-05 23:41:25 +01:00
solo6x10 media: solo6x10: Switch to using the new API kobj_to_dev() 2021-03-11 11:59:43 +01:00
sta2x11 media updates for v5.13-rc1 2021-04-28 09:24:36 -07:00
ttpci media: ttpci: switch from 'pci_' to 'dma_' API 2021-06-02 13:16:55 +02:00
tw68 media: tw68: switch from 'pci_' to 'dma_' API 2021-04-06 16:07:42 +02:00
tw686x media: tw686x: switch from 'pci_' to 'dma_' API 2021-04-06 16:07:26 +02:00
tw5864 media: pci: tw5864: avoid usage of some characters 2021-06-04 08:11:12 +02:00
Kconfig Revert "media: Kconfig: better support hybrid TV devices" 2020-04-14 11:00:30 +02:00
Makefile media: zoran: move to staging in preparation for removal 2018-05-25 15:21:36 -04:00