linux-stable/drivers
Xiaomeng Tong f467bef599 media: uvcvideo: Fix missing check to determine if element is found in list
[ Upstream commit 261f33388c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:48 +02:00
..
accessibility
acpi ACPI: CPPC: Assume no transition latency if no PCCT 2022-06-09 10:25:29 +02:00
amba
android
ata
atm
auxdisplay
base device property: Allow error pointer to be passed to fwnode APIs 2022-06-09 10:25:40 +02:00
bcma
block virtio_blk: fix the discard_granularity and discard_alignment queue limits 2022-06-09 10:25:46 +02:00
bluetooth Bluetooth: btusb: Set HCI_QUIRK_BROKEN_ERR_DATA_REPORTING for QCA 2022-06-09 10:25:28 +02:00
bus
cdrom
char char: tpm: cr50_i2c: Suppress duplicated error message in .remove() 2022-06-09 10:25:31 +02:00
clk clk: at91: generated: consider range when calculating best rate 2022-05-25 09:59:08 +02:00
clocksource
comedi
connector
counter
cpufreq cpufreq: Fix possible race in cpufreq online error path 2022-06-09 10:25:41 +02:00
cpuidle cpuidle: PSCI: Improve support for suspend-to-RAM for PSCI OSI mode 2022-06-09 10:25:21 +02:00
crypto powerpc/powernv/vas: Assign real address to rx_fifo in vas_rx_win_attr 2022-06-09 10:25:34 +02:00
cxl
dax
dca
devfreq PM / devfreq: rk3399_dmc: Disable edev on remove() 2022-06-09 10:25:32 +02:00
dio
dma
dma-buf dma-buf: ensure unique directory name for dmabuf stats 2022-05-25 09:59:04 +02:00
edac EDAC/dmc520: Don't print an error for each unconfigured interrupt line 2022-06-09 10:25:40 +02:00
eisa
extcon
firewire firewire: core: extend card->lock in fw_core_handle_bus_reset 2022-05-12 12:32:20 +02:00
firmware efi: Allow to enable EFI runtime services by default on RT 2022-06-09 10:25:40 +02:00
fpga
fsi
gnss
gpio gpio: mvebu/pwm: Refuse requests with inverted polarity 2022-05-25 09:59:12 +02:00
gpu drm/msm: return an error pointer in msm_gem_prime_get_sg_table() 2022-06-09 10:25:48 +02:00
greybus
hid HID: elan: Fix potential double free in elan_input_configured 2022-06-09 10:25:40 +02:00
hsi
hv
hwmon hwmon: (f71882fg) Fix negative temperature 2022-05-18 10:28:16 +02:00
hwspinlock
hwtracing
i2c i2c: ismt: prevent memory corruption in ismt_access() 2022-06-06 08:47:50 +02:00
i3c
idle
iio
infiniband RDMA/hfi1: Prevent panic when SDMA is disabled 2022-06-09 10:25:35 +02:00
input Input: gpio-keys - cancel delayed work only in case of GPIO 2022-06-09 10:25:35 +02:00
interconnect interconnect: Restore sync state by ignoring ipa-virt in provider count 2022-05-18 10:28:18 +02:00
iommu iommu/vt-d: Add RPLS to quirk list to skip TE disabling 2022-06-09 10:25:17 +02:00
ipack
irqchip irqchip/aspeed-scu-ic: Fix irq_of_parse_and_map() return value 2022-06-09 10:25:47 +02:00
isdn
leds
macintosh macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled 2022-06-09 10:25:35 +02:00
mailbox
mcb
md md/bitmap: don't set sb values if can't pass sanity check 2022-06-09 10:25:22 +02:00
media media: uvcvideo: Fix missing check to determine if element is found in list 2022-06-09 10:25:48 +02:00
memory
memstick
message
mfd
misc
mmc drivers: mmc: sdhci_am654: Add the quirk to set TESTCD bit 2022-06-09 10:25:22 +02:00
most
mtd mtd: rawnand: intel: fix possible null-ptr-deref in ebu_nand_probe() 2022-06-09 10:25:44 +02:00
mux
net ath9k_htc: fix potential out of bounds access with invalid rxstatus->rs_keyix 2022-06-09 10:25:42 +02:00
nfc nfc: pn533: Fix buggy cleanup order 2022-06-06 08:47:50 +02:00
ntb
nubus
nvdimm
nvme nvme: set non-mdts limits in nvme_scan_work 2022-06-09 10:25:29 +02:00
nvmem
of of: overlay: do not break notify on NOTIFY_{OK|STOP} 2022-06-09 10:25:43 +02:00
opp
parisc
parport
pci PCI: cadence: Clear FLR in device capabilities register 2022-06-09 10:25:34 +02:00
pcmcia
perf
phy
pinctrl pinctrl: renesas: rzn1: Fix possible null-ptr-deref in sh_pfc_map_resources() 2022-06-09 10:25:33 +02:00
platform platform/x86: intel-hid: fix _DSM function index handling 2022-06-09 10:25:15 +02:00
pnp
power
powercap
pps
ps3
ptp ptp: ocp: have adjtime handle negative delta_ns correctly 2022-05-25 09:59:07 +02:00
pwm
rapidio
ras
regulator regulator: core: Fix enable_count imbalance with EXCLUSIVE_GET 2022-06-09 10:25:47 +02:00
remoteproc
reset
rpmsg
rtc rtc: mc146818-lib: Fix the AltCentury for AMD platforms 2022-05-25 09:59:01 +02:00
s390 s390/lcs: fix variable dereferenced before check 2022-05-18 10:28:15 +02:00
sbus
scsi scsi: ufs: core: Exclude UECxx from SFR dump list 2022-06-09 10:25:44 +02:00
sh
siox
slimbus slimbus: qcom: Fix IRQ check in qcom_slim_probe 2022-05-18 10:28:20 +02:00
soc soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc 2022-06-09 10:25:32 +02:00
soundwire
spi spi: cadence-quadspi: fix Direct Access Mode disable for SoCFPGA 2022-06-09 10:25:46 +02:00
spmi
ssb
staging media: hantro: Empty encoder capture buffers by default 2022-06-09 10:25:42 +02:00
target target: remove an incorrect unmap zeroes data deduction 2022-06-09 10:25:40 +02:00
tc
tee
thermal thermal: int340x: Fix attr.show callback prototype 2022-05-09 09:16:30 +02:00
thunderbolt
tty serial: 8250_mtk: Fix register address for XON/XOFF character 2022-05-18 10:28:20 +02:00
uio
usb xhci: Allow host runtime PM as default for Intel Alder Lake N xHCI 2022-06-09 10:25:15 +02:00
vdpa vdpa/mlx5: Use consistent RQT size 2022-05-25 09:59:11 +02:00
vfio
vhost Fix double fget() in vhost_net_set_backend() 2022-05-25 09:59:03 +02:00
video fbcon: Consistently protect deferred_takeover with console_lock() 2022-06-09 10:25:19 +02:00
virt
virtio
visorbus
vlynq
vme
w1
watchdog Watchdog: sp5100_tco: Enable Family 17h+ CPUs 2022-05-25 09:58:58 +02:00
xen
zorro
Kconfig
Makefile