linux-stable/include/media
Hans Verkuil a0d6e64b34 media: cec: fix a deadlock situation
commit a9e6107616 upstream.

The cec_devnode struct has a lock meant to serialize access
to the fields of this struct. This lock is taken during
device node (un)registration and when opening or releasing a
filehandle to the device node. When the last open filehandle
is closed the cec adapter might be disabled by calling the
adap_enable driver callback with the devnode.lock held.

However, if during that callback a message or event arrives
then the driver will call one of the cec_queue_event()
variants in cec-adap.c, and those will take the same devnode.lock
to walk the open filehandle list.

This obviously causes a deadlock.

This is quite easy to reproduce with the cec-gpio driver since that
uses the cec-pin framework which generated lots of events and uses
a kernel thread for the processing, so when adap_enable is called
the thread is still running and can generate events.

But I suspect that it might also happen with other drivers if an
interrupt arrives signaling e.g. a received message before adap_enable
had a chance to disable the interrupts.

This patch adds a new mutex to serialize access to the fhs list.
When adap_enable() is called the devnode.lock mutex is held, but
not devnode.lock_fhs. The event functions in cec-adap.c will now
use devnode.lock_fhs instead of devnode.lock, ensuring that it is
safe to call those functions from the adap_enable callback.

This specific issue only happens if the last open filehandle is closed
and the physical address is invalid. This is not something that
happens during normal operation, but it does happen when monitoring
CEC traffic (e.g. cec-ctl --monitor) with an unconfigured CEC adapter.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: <stable@vger.kernel.org>  # for v5.13 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-27 11:02:53 +01:00
..
davinci media: vpbe_osd.h/uvcvideo.h includes: fix trivial kernel-doc warnings 2021-03-22 10:24:07 +01:00
drv-intf
i2c media: media/i2c: fix kerneldoc issues for media i2c headers 2021-03-22 10:23:43 +01:00
tpg
cec-notifier.h
cec-pin.h
cec.h media: cec: fix a deadlock situation 2022-01-27 11:02:53 +01:00
demux.h
dmxdev.h
dvb-usb-ids.h media: dvbsky: add support for MyGica T230C2_LITE and T230A 2021-07-12 09:16:29 +02:00
dvb_ca_en50221.h
dvb_demux.h
dvb_frontend.h
dvb_math.h
dvb_net.h
dvb_ringbuffer.h
dvb_vb2.h
dvbdev.h media: dvbdev: Switch to new kerneldoc syntax for named variable macro argument 2021-03-11 11:59:45 +01:00
frame_vector.h
hevc-ctrls.h media: hevc: Add segment address field 2021-07-12 09:16:32 +02:00
imx.h
media-dev-allocator.h media: Fix Media Controller API config checks 2021-06-24 14:26:00 +02:00
media-device.h
media-devnode.h
media-entity.h media: entity: Add lockdep check to media graph walk 2021-04-06 14:35:14 +02:00
media-request.h
rc-core.h media: rc: rename s_learning_mode() to s_wideband_receiver() 2021-07-22 08:21:53 +02:00
rc-map.h media: rc: add keymap for Toshiba CT-90405 remote 2021-06-08 15:56:58 +02:00
rcar-fcp.h
tuner-types.h
tuner.h
tveeprom.h
v4l2-async.h media: Documentation: media: Fix v4l2-async kerneldoc syntax 2021-08-04 14:43:50 +02:00
v4l2-common.h
v4l2-ctrls.h media: uapi: move MPEG-2 stateless controls out of staging 2021-05-23 19:21:31 +02:00
v4l2-dev.h
v4l2-device.h
v4l2-dv-timings.h
v4l2-event.h
v4l2-fh.h
v4l2-flash-led-class.h
v4l2-fwnode.h media: v4l: fwnode: Rename and make static V4L2 async notifier helper 2021-04-06 14:35:59 +02:00
v4l2-h264.h media: core headers: fix kernel-doc warnings 2021-03-22 10:22:22 +01:00
v4l2-image-sizes.h
v4l2-ioctl.h
v4l2-jpeg.h media: Add parsing for APP14 data segment in jpeg helpers 2021-03-22 10:35:36 +01:00
v4l2-mc.h media: v4l2-mc: Add link flags to v4l2_create_fwnode_links_to_pad() 2021-03-11 11:59:52 +01:00
v4l2-mediabus.h
v4l2-mem2mem.h
v4l2-rect.h
v4l2-subdev.h media: v4l: subdev: Add pre_streamon and post_streamoff callbacks 2021-08-04 14:43:51 +02:00
videobuf-core.h
videobuf-dma-contig.h
videobuf-dma-sg.h
videobuf-vmalloc.h
videobuf2-core.h media: videobuf2: rework vb2_mem_ops API 2021-11-18 19:16:13 +01:00
videobuf2-dma-contig.h
videobuf2-dma-sg.h
videobuf2-dvb.h
videobuf2-memops.h
videobuf2-v4l2.h media: videobuf2-v4l2.c: add vb2_queue_change_type() helper 2021-06-08 12:04:08 +02:00
videobuf2-vmalloc.h
vsp1.h