diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2018-09-11 05:32:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-13 09:09:28 +0200 |
commit | 10c134df948c2d581f5b89a44072a07ba8cf4069 (patch) | |
tree | a26e64580f7f7a76eac454ccaa85b603ea4fb57c /include | |
parent | a46148c3ec2d0a74b646d9e34195cc0aafa0c6ad (diff) | |
download | linux-stable-10c134df948c2d581f5b89a44072a07ba8cf4069.tar.gz linux-stable-10c134df948c2d581f5b89a44072a07ba8cf4069.tar.bz2 linux-stable-10c134df948c2d581f5b89a44072a07ba8cf4069.zip |
media: v4l: event: Prevent freeing event subscriptions while accessed
commit ad608fbcf166fec809e402d548761768f602702c upstream.
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: c3b5b0241f62 ("V4L/DVB: V4L: Events: Add backend")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/media/v4l2-fh.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h index 803516775162..4fdcd0d807d7 100644 --- a/include/media/v4l2-fh.h +++ b/include/media/v4l2-fh.h @@ -43,6 +43,7 @@ struct v4l2_fh { wait_queue_head_t wait; struct list_head subscribed; /* Subscribed events */ struct list_head available; /* Dequeueable event */ + struct mutex subscribe_lock; unsigned int navailable; u32 sequence; |