After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776107 - qtdemux: Crashes when parsing edit lists due to missing size checks
qtdemux: Crashes when parsing edit lists due to missing size checks
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.10.x
Other Linux
: Normal critical
: 1.10.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-12-14 18:38 UTC by blawlt
Modified: 2016-12-22 12:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
poc of crash (1.01 MB, video/3gpp)
2016-12-14 18:38 UTC, blawlt
  Details
qtdemux: Check if we have enough data available when parsing edit lists (3.51 KB, patch)
2016-12-14 19:46 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description blawlt 2016-12-14 18:38:02 UTC
Created attachment 341969 [details]
poc of crash

Did not have a lot of time to look into exactly what is going on here, but __gst_fast_read_swap32 segfaults while attempting an endianness swap during the demuxing of the video. This one gets there through mp4, but due to the nature of the files gst deals with presumably this can be reached through other paths as well. 

Output from asan follows and a sample file producing the crash in the latest version. 

=================================================================
==21817==ERROR: AddressSanitizer: SEGV on unknown address 0x625000080000 (pc 0x7faa56155a2c bp 0x7faa55d17420 sp 0x7faa55d17420 T3)
    #0 0x7faa56155a2b in __gst_fast_read_swap32 /usr/include/gstreamer-1.0/gst/gstutils.h:131
    #1 0x7faa5617941d in qtdemux_parse_segments /home/fuzzy/src/gst-plugins-good-1.10.2/gst/isomp4/qtdemux.c:8680
    #2 0x7faa56182e22 in qtdemux_parse_trak /home/fuzzy/src/gst-plugins-good-1.10.2/gst/isomp4/qtdemux.c:10900
    #3 0x7faa56188649 in qtdemux_parse_tree /home/fuzzy/src/gst-plugins-good-1.10.2/gst/isomp4/qtdemux.c:12495
    #4 0x7faa56163e3a in gst_qtdemux_loop_state_header /home/fuzzy/src/gst-plugins-good-1.10.2/gst/isomp4/qtdemux.c:4191
    #5 0x7faa5616c989 in gst_qtdemux_loop /home/fuzzy/src/gst-plugins-good-1.10.2/gst/isomp4/qtdemux.c:5723
    #6 0x7faa5cd9eb40  (/usr/lib/libgstreamer-1.0.so.0+0xa6b40)
    #7 0x7faa5c805acd  (/usr/lib/libglib-2.0.so.0+0x72acd)
    #8 0x7faa5c8050d4  (/usr/lib/libglib-2.0.so.0+0x720d4)
    #9 0x7faa5c279453 in start_thread (/usr/lib/libpthread.so.0+0x7453)
    #10 0x7faa5bfbc7de in __GI___clone (/usr/lib/libc.so.6+0xe87de)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/include/gstreamer-1.0/gst/gstutils.h:131 in __gst_fast_read_swap32
Thread T3 (qtdemux0:sink) created by T2 (typefind:sink) here:
    #0 0x7faa5d99d498 in __interceptor_pthread_create /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cc:236
    #1 0x7faa5c822b9f  (/usr/lib/libglib-2.0.so.0+0x8fb9f)

Thread T2 (typefind:sink) created by T1 (GstPlayer) here:
    #0 0x7faa5d99d498 in __interceptor_pthread_create /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cc:236
    #1 0x7faa5c822b9f  (/usr/lib/libglib-2.0.so.0+0x8fb9f)

Thread T1 (GstPlayer) created by T0 here:
    #0 0x7faa5d99d498 in __interceptor_pthread_create /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cc:236
    #1 0x7faa5c822b9f  (/usr/lib/libglib-2.0.so.0+0x8fb9f)

==21817==ABORTING
Comment 1 Sebastian Dröge (slomo) 2016-12-14 19:31:56 UTC
Confirmed here
Comment 2 Sebastian Dröge (slomo) 2016-12-14 19:46:06 UTC
Created attachment 341972 [details] [review]
qtdemux: Check if we have enough data available when parsing edit lists

Also consume the data entry by entry to get complicated indexing out of
the code.
Comment 3 Sebastian Dröge (slomo) 2016-12-14 19:47:25 UTC
__gst_fast_read_swap32() is used by GST_READ_UINT32_BE(). That's just reading a 32 bit integer in big endian order from some memory address, and swaps it into native endianness. The problem is not that function, but that qtdemux is calling it without checking that the memory there is actually readable.
Comment 4 Sebastian Dröge (slomo) 2016-12-14 19:48:36 UTC
Attachment 341972 [details] pushed as 76c007d - qtdemux: Check if we have enough data available when parsing edit lists
Comment 5 Sebastian Dröge (slomo) 2016-12-14 19:49:59 UTC
Thanks for reporting! I'll merge it into 1.10 soonish and it will be part of the 1.10.3 release
Comment 6 blawlt 2016-12-14 20:01:06 UTC
Nice, thanks for posting the diff that is enlightening. I also appreciate the further explanation, interesting stuff. 

Glad I could help :)
Comment 7 Sebastian Dröge (slomo) 2016-12-15 10:53:13 UTC
Sure, just ask if something is not clear and let us know if you find more