gstreamer/subprojects
Matthew Waters 598f2ab73f rtspconnection: protect cancellable by a mutex
It is entirely possible for the cancellable to be cancelled (and freed)
in gst_rtsp_connection_flush() while there may be an ongoing read/write
operation.

Nothing prevents gst_rtsp_connection_flush() from waiting for the
outstanding read/writes.

This could lead to a crash like (where cancellable has been freed
within gst_rtsp_connection_flush()):

 #0  0x00007ffff4351096 in g_output_stream_writev (stream=stream@entry=0x7fff30002950, vectors=vectors@entry=0x7ffe2c6afa80, n_vectors=n_vectors@entry=3, bytes_written=bytes_written@entry=0x7ffe2c6af950,  cancellable=cancellable@entry=0x7fff300288a0, error=error@entry=0x7ffe2c6af958) at ../subprojects/glib/gio/goutputstream.c:377
 #1  0x00007ffff44b2c38 in writev_bytes (stream=0x7fff30002950, vectors=vectors@entry=0x7ffe2c6afa80, n_vectors=n_vectors@entry=3, bytes_written=bytes_written@entry=0x7ffe2c6afb90, block=block@entry=1, cancellable=0x7fff300288a0) at ../subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c:1320
 #2  0x00007ffff44b583e in gst_rtsp_connection_send_messages_usec (conn=0x7fff30001370, messages=messages@entry=0x7ffe2c6afcc0, n_messages=n_messages@entry=1, timeout=timeout@entry=3000000) at ../subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c:2056
 #3  0x00007ffff44d2669 in gst_rtsp_client_sink_connection_send_messages (sink=0x7fffac0192c0, timeout=3000000, n_messages=1, messages=0x7ffe2c6afcc0, conninfo=0x7fffac019610) at ../subprojects/gst-rtsp-server/gst/rtsp-sink/gstrtspclientsink.c:1929
 #4  gst_rtsp_client_sink_try_send (sink=sink@entry=0x7fffac0192c0, conninfo=conninfo@entry=0x7fffac019610, requests=requests@entry=0x7ffe2c6afcc0, n_requests=n_requests@entry=1, response=response@entry=0x0, code=code@entry=0x0) at ../subprojects/gst-rtsp-server/gst/rtsp-sink/gstrtspclientsink.c:2845
 #5  0x00007ffff44d3077 in do_send_data (buffer=0x7fff38075c60, channel=<optimized out>, context=0x7fffac042640) at ../subprojects/gst-rtsp-server/gst/rtsp-sink/gstrtspclientsink.c:3896
 #6  0x00007ffff4281cc6 in gst_rtsp_stream_transport_send_rtp (trans=trans@entry=0x7fff20061f80, buffer=<optimized out>) at ../subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream-transport.c:632
 #7  0x00007ffff4278e9b in push_data (stream=0x7fff40019bf0, is_rtp=<optimized out>, buffer_list=0x0, buffer=<optimized out>, trans=0x7fff20061f80) at ../subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c:2586
 #8  check_transport_backlog (stream=0x7fff40019bf0, trans=0x7fff20061f80) at ../subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c:2645
 #9  0x00007ffff42793b3 in send_tcp_message (idx=<optimized out>, stream=0x7fff40019bf0) at ../subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c:2741
 #10 send_func (stream=0x7fff40019bf0) at ../subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c:2776
 #11 0x00007ffff7d59fad in g_thread_proxy (data=0x7fffbc062920) at ../subprojects/glib/glib/gthread.c:827
 #12 0x00007ffff7a8ce2d in start_thread () from /lib64/libc.so.6
 #13 0x00007ffff7b12620 in clone3 () from /lib64/libc.so.6

Fix by adding a cancellable lock and returning an extra reference used
across all read/write operations.  gst_rtsp_connection_flush() can free
the in-use cancellable and it will no longer affect any in progress
read/write.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2799>
2022-07-28 10:32:15 +00:00
..
gst-devtools coding style: allow declarations after statement 2022-06-29 13:40:25 +00:00
gst-docs webrtc: Split WebRTCICE into base classes and implementation. 2022-07-26 13:51:11 +00:00
gst-editing-services coding style: allow declarations after statement 2022-06-29 13:40:25 +00:00
gst-examples webrtc: Split WebRTCICE into base classes and implementation. 2022-07-26 13:51:11 +00:00
gst-integration-testsuites test: update tests to include the new meta 2022-06-03 08:29:05 +00:00
gst-libav libav: Fix for APNG encoder property registration 2022-07-08 13:56:35 +00:00
gst-omx coding style: allow declarations after statement 2022-06-29 13:40:25 +00:00
gst-plugins-bad va: h264enc: Make AUD the first NAL unit 2022-07-27 06:46:21 +00:00
gst-plugins-base rtspconnection: protect cancellable by a mutex 2022-07-28 10:32:15 +00:00
gst-plugins-good videoflip: Fix caps negotiation when method is selected 2022-07-28 00:00:47 +00:00
gst-plugins-ugly coding style: allow declarations after statement 2022-06-29 13:40:25 +00:00
gst-python python: Fix the audiotestsrc example 2022-07-08 14:37:14 +00:00
gst-rtsp-server rtsp-client: Fix url for generating key in media factory 2022-07-12 10:01:35 +00:00
gstreamer GST_CHECK_VERSION: Fix unexpected "git = next version" assumption 2022-07-28 08:52:13 +00:00
gstreamer-sharp gstreamer-sharp: apply new code style to alll sources 2022-04-05 08:28:50 +00:00
gstreamer-vaapi vaapi: h265dec: avoid possible NULL deref 2022-07-27 08:45:45 -04:00
macos-bison-binary meson: Fix warning about check kwarg 2022-07-16 06:16:17 +00:00
packagefiles meson: Fix compile failures on macOS in harfbuzz and pango 2022-07-16 06:16:17 +00:00
win-flex-bison-binaries
win-nasm
avtp.wrap subprojects/avtp: Update to latest avtp 0.2.0 2022-03-18 22:49:16 +00:00
bindinator.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
cairo.wrap meson: Build cairo subproject when unavailable on the system 2022-01-21 06:34:33 +00:00
dav1d.wrap
dssim.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
dv.wrap
expat.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00
fdk-aac.wrap subprojects: fdk-aac: add fallback_url 2021-10-28 23:29:27 +00:00
FFmpeg.wrap wraps:ffmpeg: Move to 4.4 2021-10-15 02:32:40 +00:00
fontconfig.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
freetype2.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
fribidi.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
gl-headers.wrap Move files from gst-plugins-base into the "subprojects/gst-plugins-base/" subdir 2021-09-24 16:13:26 -03:00
glib-networking.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
glib.wrap meson: Update subprojects to fix warnings 2022-01-25 14:25:19 +05:30
graphene.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
gst-plugins-rs.wrap subprojects: Switch gst-plugins-rs.wrap to the main branch 2022-02-16 09:54:07 +02:00
gtk-sharp.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
harfbuzz.wrap meson: Fix compile failures on macOS in harfbuzz and pango 2022-07-16 06:16:17 +00:00
json-glib.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
lame.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00
libdrm.wrap meson: Update subprojects to fix warnings 2022-01-25 14:25:19 +05:30
libffi.wrap
libjpeg-turbo.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00
libmicrodns.wrap
libnice.wrap subprojects: Update libnice to 0.1.19 2022-05-03 18:49:36 -04:00
libopenjp2.wrap Update openjp2 and libxml2 from wrapdb 2022-03-31 14:19:46 -04:00
libpng.wrap subprojects/libpng: Update to latest wrap file 2022-01-28 02:01:39 +05:30
libpsl.wrap
libsoup.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
libwpe.wrap
libxml2.wrap Update openjp2 and libxml2 from wrapdb 2022-03-31 14:19:46 -04:00
ogg.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00
openh264.wrap Update openh264 wrap to v2.2.0 + fixes from master 2022-04-09 21:44:42 +01:00
opus.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
orc.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
pango.wrap meson: Fix compile failures on macOS in harfbuzz and pango 2022-07-16 06:16:17 +00:00
pixman.wrap meson: Update subprojects to fix warnings 2022-01-25 14:25:19 +05:30
proxy-libintl.wrap Update proxy-libintl wrap to 0.4 2022-04-22 15:36:40 +00:00
pycairo.wrap
pygobject.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
sqlite3.wrap Update wrap files from latest wrapdb version 2022-03-07 17:47:09 +00:00
vorbis.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00
webrtc-audio-processing.wrap Pin all wrap files to closest tag or commit sha1 2021-10-14 22:34:49 +00:00
wpebackend-fdo.wrap
x264.wrap
zlib.wrap meson: Update some wraps, remove unused wraps 2022-07-16 06:16:17 +00:00