linux/drivers/media
Xiaomeng Tong 261f33388c media: uvcvideo: Fix missing check to determine if element is found in list
The list iterator will point to a bogus position containing HEAD if
the list is empty or the element is not found in list. This case
should be checked before any use of the iterator, otherwise it will
lead to a invalid memory access. The missing check here is before
"pin = iterm->id;", just add check here to fix the security bug.

In addition, the list iterator value will *always* be set and non-NULL
by list_for_each_entry(), so it is incorrect to assume that the iterator
value will be NULL if the element is not found in list, considering
the (mis)use here: "if (iterm == NULL".

Use a new value 'it' as the list iterator, while use the old value
'iterm' as a dedicated pointer to point to the found element, which
1. can fix this bug, due to 'iterm' is NULL only if it's not found.
2. do not need to change all the uses of 'iterm' after the loop.
3. can also limit the scope of the list iterator 'it' *only inside*
   the traversal loop by simply declaring 'it' inside the loop in the
   future, as usage of the iterator outside of the list_for_each_entry
   is considered harmful. https://lkml.org/lkml/2022/2/17/1032

Fixes: d5e90b7a6c ("[media] uvcvideo: Move to video_ioctl2")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-05-08 07:08:53 +02:00
..
cec media: cec: add optional adap_configured callback 2022-04-24 07:41:35 +01:00
common media: v4l: ioctl: Set bus_info in v4l_querycap() 2022-04-24 08:07:08 +01:00
dvb-core media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
dvb-frontends media: media/*/Kconfig: sort entries 2022-03-18 05:58:35 +01:00
firewire media: Makefiles: remove extra spaces 2022-03-12 16:59:52 +01:00
i2c media: i2c: dw9714: Return zero in remove callback 2022-04-24 08:26:45 +01:00
mc media: mc: delete redundant code in __media_device_unregister_entity 2022-04-24 08:14:19 +01:00
mmc media: media/*/Kconfig: sort entries 2022-03-18 05:58:35 +01:00
pci media: saa7134: simplify if-if to if-else 2022-04-24 08:51:10 +01:00
platform media: platform: imx-mipi-csis: Remove unneeded 'default n' 2022-04-24 09:07:31 +01:00
radio media: v4l: ioctl: Set bus_info in v4l_querycap() 2022-04-24 08:07:08 +01:00
rc media: gpio-ir-tx: simplify wait logic 2022-05-08 07:07:16 +02:00
spi media updates for v5.18-rc1 2022-03-23 14:51:35 -07:00
test-drivers media: vidtv: use vfree() for memory allocated with vzalloc() 2022-03-18 07:28:17 +01:00
tuners media: si2157: unknown chip version Si2147-A30 ROM 0x50 2022-04-09 17:45:49 +02:00
usb media: uvcvideo: Fix missing check to determine if element is found in list 2022-05-08 07:08:53 +02:00
v4l2-core media: v4l2: fix uninitialized value tuner_status(CWE-457) 2022-04-24 08:49:53 +01:00
Kconfig media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
Makefile media: Makefiles: remove extra spaces 2022-03-12 16:59:52 +01:00