linux_old1/drivers/media/v4l2-core
Sakari Ailus ad608fbcf1 media: v4l: event: Prevent freeing event subscriptions while accessed
The event subscriptions are added to the subscribed event list while
holding a spinlock, but that lock is subsequently released while still
accessing the subscription object. This makes it possible to unsubscribe
the event --- and freeing the subscription object's memory --- while
the subscription object is simultaneously accessed.

Prevent this by adding a mutex to serialise the event subscription and
unsubscription. This also gives a guarantee to the callback ops that the
add op has returned before the del op is called.

This change also results in making the elems field less special:
subscriptions are only added to the event list once they are fully
initialised.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@vger.kernel.org # for 4.14 and up
Fixes: c3b5b0241f ("V4L/DVB: V4L: Events: Add backend")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-03 06:32:51 -04:00
..
Kconfig media: Remove depends on HAS_DMA in case of platform dependency 2018-05-28 16:17:08 -04:00
Makefile media: v4l2-core: get rid of videobuf-dvb 2018-05-04 10:57:31 -04:00
tuner-core.c media: add tuner standby op, use where needed 2018-03-21 12:05:39 -04:00
v4l2-async.c media: v4l2-async: simplify v4l2_async_subdev structure 2017-12-29 07:14:28 -05:00
v4l2-clk.c media: Convert to using %pOF instead of full_name 2017-08-20 08:20:20 -04:00
v4l2-common.c media: v4l: common: Remove v4l2_find_nearest_format 2018-03-21 11:21:33 -04:00
v4l2-compat-ioctl32.c media: v4l2-compat-ioctl32: better document the code 2018-04-20 08:24:13 -04:00
v4l2-ctrls.c media: v4l2-ctrl: Add control for VP9 profile 2018-07-04 09:32:22 -04:00
v4l2-dev.c media: add helpers for memory-to-memory media controller 2018-07-04 08:43:47 -04:00
v4l2-device.c media: mark entity-intf links as IMMUTABLE 2018-07-04 08:40:49 -04:00
v4l2-dv-timings.c media: v4l2-dv-timings: add v4l2_hdmi_colorimetry() 2018-02-22 12:41:09 -05:00
v4l2-event.c media: v4l: event: Prevent freeing event subscriptions while accessed 2018-10-03 06:32:51 -04:00
v4l2-fh.c media: v4l: event: Prevent freeing event subscriptions while accessed 2018-10-03 06:32:51 -04:00
v4l2-flash-led-class.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
v4l2-fwnode.c media updates for v4.19-rc1 2018-08-15 18:29:14 -07:00
v4l2-ioctl.c media: v4l: Add new 10-bit packed grayscale format 2018-08-02 06:07:05 -04:00
v4l2-mc.c media: v4l2-core: v4l2-mc: Add SPDX license identifier 2018-02-26 07:42:03 -05:00
v4l2-mem2mem.c media: v4l2-mem2mem: add descriptions to MC fields 2018-08-07 06:10:16 -04:00
v4l2-subdev.c media: v4l: Add support for STD ioctls on subdev nodes 2018-07-24 17:39:28 -04:00
v4l2-trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
videobuf-core.c MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00
videobuf-dma-contig.c MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00
videobuf-dma-sg.c treewide: Use array_size() in vzalloc() 2018-06-12 16:19:22 -07:00
videobuf-vmalloc.c MAINTAINERS & files: Canonize the e-mails I use at files 2018-05-04 06:21:06 -04:00