linux-yocto/drivers
Thadeu Lima de Souza Cascardo f617d515d6 media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
commit 0e2ee70291e64a30fe36960c85294726d34a103e upstream.

Per UVC 1.1+ specification 3.7.2, units and terminals must have a non-zero
unique ID.

```
Each Unit and Terminal within the video function is assigned a unique
identification number, the Unit ID (UID) or Terminal ID (TID), contained in
the bUnitID or bTerminalID field of the descriptor. The value 0x00 is
reserved for undefined ID,
```

If we add a new entity with id 0 or a duplicated ID, it will be marked
as UVC_INVALID_ENTITY_ID.

In a previous attempt commit 3dd075fe8e ("media: uvcvideo: Require
entities to have a non-zero unique ID"), we ignored all the invalid units,
this broke a lot of non-compatible cameras. Hopefully we are more lucky
this time.

This also prevents some syzkaller reproducers from triggering warnings due
to a chain of entities referring to themselves. In one particular case, an
Output Unit is connected to an Input Unit, both with the same ID of 1. But
when looking up for the source ID of the Output Unit, that same entity is
found instead of the input entity, which leads to such warnings.

In another case, a backward chain was considered finished as the source ID
was 0. Later on, that entity was found, but its pads were not valid.

Here is a sample stack trace for one of those cases.

[   20.650953] usb 1-1: new high-speed USB device number 2 using dummy_hcd
[   20.830206] usb 1-1: Using ep0 maxpacket: 8
[   20.833501] usb 1-1: config 0 descriptor??
[   21.038518] usb 1-1: string descriptor 0 read error: -71
[   21.038893] usb 1-1: Found UVC 0.00 device <unnamed> (2833:0201)
[   21.039299] uvcvideo 1-1:0.0: Entity type for entity Output 1 was not initialized!
[   21.041583] uvcvideo 1-1:0.0: Entity type for entity Input 1 was not initialized!
[   21.042218] ------------[ cut here ]------------
[   21.042536] WARNING: CPU: 0 PID: 9 at drivers/media/mc/mc-entity.c:1147 media_create_pad_link+0x2c4/0x2e0
[   21.043195] Modules linked in:
[   21.043535] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:1 Not tainted 6.11.0-rc7-00030-g3480e43aeccf #444
[   21.044101] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014
[   21.044639] Workqueue: usb_hub_wq hub_event
[   21.045100] RIP: 0010:media_create_pad_link+0x2c4/0x2e0
[   21.045508] Code: fe e8 20 01 00 00 b8 f4 ff ff ff 48 83 c4 30 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc 0f 0b eb e9 0f 0b eb 0a 0f 0b eb 06 <0f> 0b eb 02 0f 0b b8 ea ff ff ff eb d4 66 2e 0f 1f 84 00 00 00 00
[   21.046801] RSP: 0018:ffffc9000004b318 EFLAGS: 00010246
[   21.047227] RAX: ffff888004e5d458 RBX: 0000000000000000 RCX: ffffffff818fccf1
[   21.047719] RDX: 000000000000007b RSI: 0000000000000000 RDI: ffff888004313290
[   21.048241] RBP: ffff888004313290 R08: 0001ffffffffffff R09: 0000000000000000
[   21.048701] R10: 0000000000000013 R11: 0001888004313290 R12: 0000000000000003
[   21.049138] R13: ffff888004313080 R14: ffff888004313080 R15: 0000000000000000
[   21.049648] FS:  0000000000000000(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000
[   21.050271] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   21.050688] CR2: 0000592cc27635b0 CR3: 000000000431c000 CR4: 0000000000750ef0
[   21.051136] PKRU: 55555554
[   21.051331] Call Trace:
[   21.051480]  <TASK>
[   21.051611]  ? __warn+0xc4/0x210
[   21.051861]  ? media_create_pad_link+0x2c4/0x2e0
[   21.052252]  ? report_bug+0x11b/0x1a0
[   21.052540]  ? trace_hardirqs_on+0x31/0x40
[   21.052901]  ? handle_bug+0x3d/0x70
[   21.053197]  ? exc_invalid_op+0x1a/0x50
[   21.053511]  ? asm_exc_invalid_op+0x1a/0x20
[   21.053924]  ? media_create_pad_link+0x91/0x2e0
[   21.054364]  ? media_create_pad_link+0x2c4/0x2e0
[   21.054834]  ? media_create_pad_link+0x91/0x2e0
[   21.055131]  ? _raw_spin_unlock+0x1e/0x40
[   21.055441]  ? __v4l2_device_register_subdev+0x202/0x210
[   21.055837]  uvc_mc_register_entities+0x358/0x400
[   21.056144]  uvc_register_chains+0x1fd/0x290
[   21.056413]  uvc_probe+0x380e/0x3dc0
[   21.056676]  ? __lock_acquire+0x5aa/0x26e0
[   21.056946]  ? find_held_lock+0x33/0xa0
[   21.057196]  ? kernfs_activate+0x70/0x80
[   21.057533]  ? usb_match_dynamic_id+0x1b/0x70
[   21.057811]  ? find_held_lock+0x33/0xa0
[   21.058047]  ? usb_match_dynamic_id+0x55/0x70
[   21.058330]  ? lock_release+0x124/0x260
[   21.058657]  ? usb_match_one_id_intf+0xa2/0x100
[   21.058997]  usb_probe_interface+0x1ba/0x330
[   21.059399]  really_probe+0x1ba/0x4c0
[   21.059662]  __driver_probe_device+0xb2/0x180
[   21.059944]  driver_probe_device+0x5a/0x100
[   21.060170]  __device_attach_driver+0xe9/0x160
[   21.060427]  ? __pfx___device_attach_driver+0x10/0x10
[   21.060872]  bus_for_each_drv+0xa9/0x100
[   21.061312]  __device_attach+0xed/0x190
[   21.061812]  device_initial_probe+0xe/0x20
[   21.062229]  bus_probe_device+0x4d/0xd0
[   21.062590]  device_add+0x308/0x590
[   21.062912]  usb_set_configuration+0x7b6/0xaf0
[   21.063403]  usb_generic_driver_probe+0x36/0x80
[   21.063714]  usb_probe_device+0x7b/0x130
[   21.063936]  really_probe+0x1ba/0x4c0
[   21.064111]  __driver_probe_device+0xb2/0x180
[   21.064577]  driver_probe_device+0x5a/0x100
[   21.065019]  __device_attach_driver+0xe9/0x160
[   21.065403]  ? __pfx___device_attach_driver+0x10/0x10
[   21.065820]  bus_for_each_drv+0xa9/0x100
[   21.066094]  __device_attach+0xed/0x190
[   21.066535]  device_initial_probe+0xe/0x20
[   21.066992]  bus_probe_device+0x4d/0xd0
[   21.067250]  device_add+0x308/0x590
[   21.067501]  usb_new_device+0x347/0x610
[   21.067817]  hub_event+0x156b/0x1e30
[   21.068060]  ? process_scheduled_works+0x48b/0xaf0
[   21.068337]  process_scheduled_works+0x5a3/0xaf0
[   21.068668]  worker_thread+0x3cf/0x560
[   21.068932]  ? kthread+0x109/0x1b0
[   21.069133]  kthread+0x197/0x1b0
[   21.069343]  ? __pfx_worker_thread+0x10/0x10
[   21.069598]  ? __pfx_kthread+0x10/0x10
[   21.069908]  ret_from_fork+0x32/0x40
[   21.070169]  ? __pfx_kthread+0x10/0x10
[   21.070424]  ret_from_fork_asm+0x1a/0x30
[   21.070737]  </TASK>

Reported-by: syzbot+0584f746fde3d52b4675@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0584f746fde3d52b4675
Reported-by: syzbot+dd320d114deb3f5bb79b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=dd320d114deb3f5bb79b
Reported-by: Youngjun Lee <yjjuny.lee@samsung.com>
Fixes: a3fbc2e6bb ("media: mc-entity.c: use WARN_ON, validate link pads")
Cc: stable@vger.kernel.org
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Co-developed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-10-06 11:17:00 +02:00
..
accel accel/qaic: Mask out SR-IOV PCI resources 2025-06-04 14:42:15 +02:00
accessibility
acpi ACPI/IORT: Fix memory leak in iort_rmr_alloc_sids() 2025-09-09 18:56:25 +02:00
amba
android
ata ata: libata-scsi: Return aborted command when missing sense and result TF 2025-08-28 16:28:42 +02:00
atm atm: atmtcp: Prevent arbitrary write in atmtcp_recv_control(). 2025-09-04 15:30:21 +02:00
auxdisplay auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common" 2025-06-04 14:42:01 +02:00
base x86/vmscape: Enable the mitigation 2025-09-11 17:20:27 +02:00
bcma bcma: Add explicit of_device.h include 2023-04-14 15:32:56 +03:00
block loop: Avoid updating block size under exclusive owner 2025-10-02 13:42:54 +02:00
bluetooth Bluetooth: vhci: Prevent use-after-free by removing debugfs files early 2025-09-09 18:56:21 +02:00
bus bus: mhi: host: Detect events pointing to unexpected TREs 2025-08-28 16:28:33 +02:00
cache
cdrom cdrom: Avoid barrier_nospec() in cdrom_ioctl_media_changed() 2024-11-01 01:58:25 +01:00
cdx cdx: Fix off-by-one error in cdx_rpmsg_probe() 2025-08-28 16:28:45 +02:00
char ipmi: Fix strcpy source and destination the same 2025-08-28 16:28:29 +02:00
clk clk: qcom: ipq5018: keep XO clock always on 2025-08-28 16:28:26 +02:00
clocksource clocksource: mips-gic-timer: Enable counter when CPUs start 2025-06-04 14:42:06 +02:00
comedi comedi: Fix use of uninitialized memory in do_insn_ioctl() and do_insnlist_ioctl() 2025-08-28 16:28:45 +02:00
connector
counter counter: interrupt-cnt: Protect enable/disable OPs with mutex 2025-06-19 15:28:31 +02:00
cpufreq cpufreq: Initialize cpufreq-based invariance before subsys 2025-10-02 13:42:49 +02:00
cpuidle cpuidle: governors: menu: Avoid selecting states with too much latency 2025-08-28 16:28:45 +02:00
crypto crypto: qat - flush misc workqueue during device shutdown 2025-08-28 16:28:33 +02:00
cxl cxl/region: Add a dev_err() on missing target list entries 2025-07-06 11:00:06 +02:00
dax
dca Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
devfreq PM / devfreq: governor: Replace sscanf() with kstrtoul() in set_freq_store() 2025-08-28 16:28:16 +02:00
dio
dma dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate 2025-09-19 16:32:08 +02:00
dma-buf dma-buf: fix timeout handling in dma_resv_wait_timeout v2 2025-07-10 16:03:19 +02:00
edac minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
eisa EISA: Replace all non-returning strlcpy with strscpy 2023-07-27 10:04:42 -07:00
extcon
firewire firewire: core: fix overlooked update of subsystem ABI version 2025-10-02 13:42:47 +02:00
firmware firmware: tegra: Fix IVC dependency problems 2025-08-28 16:28:17 +02:00
fpga fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable() 2025-08-28 16:28:45 +02:00
fsi
gnss driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
gpio gpiolib: Extend software-node support to support secondary software-nodes 2025-10-02 13:42:54 +02:00
gpu drm/i915/backlight: Return immediately when scale() finds invalid parameters 2025-10-02 13:42:56 +02:00
greybus
hid HID: asus: add support for missing PX series fn keys 2025-10-02 13:42:52 +02:00
hsi HSI: ssi_protocol: Fix use after free vulnerability in ssi_protocol Driver Due to Race Condition 2025-04-25 10:45:38 +02:00
hte hte: tegra: Fix missing error code in tegra_hte_test_probe() 2023-11-20 11:59:08 +01:00
hv Drivers: hv: vmbus: Add utility function for querying ring size 2025-07-06 11:00:09 +02:00
hwmon minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
hwspinlock
hwtracing coresight: Only check bottom two claim bits 2025-07-06 11:00:07 +02:00
i2c i2c: designware: Add quirk for Intel Xe 2025-10-02 13:42:48 +02:00
i3c i3c: master: Initialize ret in i3c_i2c_notifier_call() 2025-08-28 16:28:28 +02:00
idle intel_idle: Allow loading ACPI tables for any family 2025-08-28 16:28:14 +02:00
iio iio: pressure: mprls0025pa: use aligned_s64 for timestamp 2025-09-09 18:56:30 +02:00
infiniband IB/mlx5: Fix obj_type mismatch for SRQ event subscriptions 2025-10-02 13:42:48 +02:00
input minmax: don't use max() in situations that want a C constant expression 2025-10-02 13:42:55 +02:00
interconnect interconnect: qcom: sc8180x: specify num_nodes 2025-08-15 12:08:44 +02:00
iommu iommu/amd/pgtbl: Fix possible race while increase page table level 2025-09-25 11:00:10 +02:00
ipack tty: make tty_operations::write()'s count size_t 2023-08-11 21:12:46 +02:00
irqchip minmax: don't use max() in situations that want a C constant expression 2025-10-02 13:42:55 +02:00
isdn mISDN: Fix memory leak in dsp_hwec_enable() 2025-09-09 18:56:22 +02:00
leds leds: flash: leds-qcom-flash: Fix registry access after re-bind 2025-08-28 16:28:40 +02:00
macintosh
mailbox mailbox: Not protect module_put with spin_lock_irqsave 2025-07-06 11:00:05 +02:00
mcb mcb: fix a double free bug in chameleon_parse_gdd() 2025-05-02 07:50:47 +02:00
md minmax: add a few more MIN_T/MAX_T users 2025-09-25 11:00:10 +02:00
media media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID 2025-10-06 11:17:00 +02:00
memory memory: omap-gpmc: drop no compatible check 2025-04-10 14:37:38 +02:00
memstick memstick: Fix deadlock by moving removing flag earlier 2025-08-28 16:28:43 +02:00
message scsi: fusion: Remove unused variable 'rc' 2024-12-09 10:32:18 +01:00
mfd mfd: axp20x: Set explicit ID for AXP313 regulator 2025-08-28 16:28:25 +02:00
misc misc: rtsx: usb: Ensure mmc child device is active when card is present 2025-08-28 16:28:31 +02:00
mmc mmc: sdhci-cadence: add Mobileye eyeQ support 2025-10-02 13:42:48 +02:00
most most: core: Drop device reference after usage in get_channel() 2025-08-28 16:28:45 +02:00
mtd mtd: nand: raw: atmel: Respect tAR, tCLR in read setup timing 2025-09-19 16:32:04 +02:00
mux mux: Explicitly include correct DT includes 2023-08-28 13:36:24 -05:00
net minmax: don't use max() in situations that want a C constant expression 2025-10-02 13:42:55 +02:00
nfc minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
ntb ntb_hw_amd: Add NTB PCI ID for new gen CPU 2025-05-02 07:50:56 +02:00
nubus
nvdimm libnvdimm/labels: Fix divide error in nd_label_data_init() 2025-06-04 14:41:56 +02:00
nvme nvme-pci: try function level reset on init failure 2025-08-28 16:28:14 +02:00
nvmem nvmem: layouts: u-boot-env: remove crc32 endianness conversion 2025-07-24 08:53:22 +02:00
of of: dynamic: Fix use after free in of_changeset_add_prop_helper() 2025-09-04 15:30:18 +02:00
opp OPP: OF: Fix an OF node leak in _opp_add_static_v2() 2025-02-08 09:51:55 +01:00
parisc
parport
pci PCI/MSI: Add an option to write MSIX ENTRY_DATA before any reads 2025-09-09 18:56:29 +02:00
pcmcia pcmcia: omap_cf: Mark driver struct with __refdata to prevent section mismatch 2025-09-25 11:00:05 +02:00
peci
perf perf/cxlpmu: Remove unintended newline from IRQ name format string 2025-08-28 16:28:21 +02:00
phy phy: ti: omap-usb2: fix device leak at unbind 2025-09-25 11:00:10 +02:00
pinctrl pinctrl: STMFX: add missing HAS_IOMEM dependency 2025-09-04 15:30:18 +02:00
platform minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
pmdomain imx8m-blk-ctrl: set ISI panic write hurry level 2025-08-28 16:28:19 +02:00
pnp
power power: supply: bq27xxx: restrict no-battery detection to bq27000 2025-09-25 11:00:07 +02:00
powercap powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw() 2025-08-15 12:08:42 +02:00
pps pps: clients: gpio: fix interrupt handling order in remove path 2025-08-28 16:28:18 +02:00
ps3 driver/ps3: Include <video/cmdline.h> for mode parsing 2023-02-20 14:56:51 +01:00
ptp ptp: Use ratelimite for freerun error message 2025-08-28 16:28:24 +02:00
pwm pwm: mediatek: Fix duty and period setting 2025-08-28 16:28:36 +02:00
rapidio drivers/rapidio/rio_cm.c: prevent possible heap overwrite 2025-06-27 11:08:58 +01:00
ras ras/debugfs: Fix error checking for debugfs_create_dir() 2023-05-16 21:12:23 +02:00
regulator regulator: sy7636a: fix lifecycle of power good gpio 2025-09-19 16:32:07 +02:00
remoteproc remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU 2025-08-28 16:28:16 +02:00
reset reset: brcmstb: Enable reset drivers for ARCH_BCM2835 2025-08-28 16:28:18 +02:00
rpmsg rpmsg: qcom_smd: Fix uninitialized return variable in __qcom_smd_send() 2025-06-19 15:28:27 +02:00
rtc rtc: pcf2127: fix SPI command byte for PCF2131 backport 2025-09-25 11:00:10 +02:00
s390 s390/sclp: Fix SCCB present check 2025-08-28 16:28:43 +02:00
sbus
scsi minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
sh sh: intc: Fix use-after-free bug in register_intc_controller() 2024-12-09 10:33:00 +01:00
siox
slimbus
soc soc: qcom: mdt_loader: Deal with zero e_shentsize 2025-09-09 18:56:27 +02:00
soundwire soundwire: Move handle_nested_irq outside of sdw_dev_lock 2025-08-28 16:28:28 +02:00
spi spi: fsl-qspi: Fix double cleanup in probe error path 2025-09-09 18:56:35 +02:00
spmi spmi: hisi-spmi-controller: Do not override device identifier 2024-06-21 14:38:40 +02:00
ssb
staging minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
target scsi: target: target_core_configfs: Add length check to avoid buffer overflow 2025-10-06 11:17:00 +02:00
tc
tee tee: optee: ffa: fix a typo of "optee_ffa_api_is_compatible" 2025-09-09 18:56:20 +02:00
thermal thermal/drivers/mediatek/lvts: Disable low offset IRQ for minimum threshold 2025-09-09 18:56:29 +02:00
thunderbolt thunderbolt: Fix copy+paste error in match_service_id() 2025-08-28 16:28:31 +02:00
tty serial: sc16is7xx: fix bug in flow control levels init 2025-09-19 16:32:05 +02:00
ufs scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE 2025-10-02 13:42:47 +02:00
uio uio_hv_generic: Align ring size to system page 2025-07-06 11:00:09 +02:00
usb usb: core: Add 0x prefix to quirks debug output 2025-10-02 13:42:48 +02:00
vdpa vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines 2025-06-04 14:42:05 +02:00
vfio vfio/mlx5: fix possible overflow in tracking max message size 2025-08-28 16:28:29 +02:00
vhost vhost/net: Protect ubufs with rcu read lock in vhost_net_ubuf_put() 2025-09-04 15:30:20 +02:00
video fbcon: Fix OOB access in font allocation 2025-10-02 13:42:54 +02:00
virt fix locking in efi_secret_unlink() 2025-08-28 16:28:15 +02:00
virtio virtio_ring: Fix error reporting in virtqueue_resize 2025-08-01 09:47:28 +01:00
vlynq
w1
watchdog watchdog: iTCO_wdt: Report error if timeout configuration fails 2025-08-28 16:28:26 +02:00
xen xen/gntdev: remove struct gntdev_copy_batch from stack 2025-08-15 12:08:47 +02:00
zorro
Kconfig
Makefile