Opened 3 years ago

Closed 21 months ago

Last modified 21 months ago

#8248 closed defect (fixed)

heap-use-after-free at libavfilter/vf_minterpolate.c:304

Reported by: Suhwan Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: asan minterpolate
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
There is a heap-use-after-free at libavfilter/vf_minterpolate.c:304 in get_sbad_ob
I compiled ffmpeg with "--toolchain=clang-asan" to check the heap buffer overflow and attached log file.

How to reproduce:

% ffmpeg_g -stream_loop 17 -y -r 94 -i $PoC -filter_complex minterpolate -target vcd -loglevel 99 -c:s:18 pcm_alaw -c:a:103 sonicls -vframes 85 -aframes 36 -strict 0 tmp.gif

ffmpeg version N-95314-g1331e00179 Copyright (c) 2000-2019 the FFmpeg developers
built with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
configuration: --cc=clang --cxx=clang++ --ld=clang --enable-debug --toolchain=clang-asan

Here's ASAN log

==18982==ERROR: AddressSanitizer: heap-use-after-free on address 0x619000004470 at pc 0x000001021720 bp 0x7fffffffa0d0 sp 0x7fffffffa0c8
READ of size 1 at 0x619000004470 thread T0
    #0 0x102171f in get_sbad_ob ffmpeg/libavfilter/vf_minterpolate.c:304:21
    #1 0x1b12270 in ff_me_search_epzs ffmpeg/libavfilter/motion_estimation.c:346:5
    #2 0x1008839 in search_mv ffmpeg/libavfilter/vf_minterpolate.c:515:13
    #3 0xfe94eb in bilateral_me ffmpeg/libavfilter/vf_minterpolate.c:585:13
    #4 0xfe94eb in inject_frame ffmpeg/libavfilter/vf_minterpolate.c:785
    #5 0xfdfc0d in filter_frame ffmpeg/libavfilter/vf_minterpolate.c:1180:15
    #6 0x827289 in ff_filter_activate_default ffmpeg/libavfilter/avfilter.c:1071:11
    #7 0x827289 in ff_filter_activate ffmpeg/libavfilter/avfilter.c:1430
    #8 0x870182 in push_frame ffmpeg/libavfilter/buffersrc.c:187:15
    #9 0x870182 in av_buffersrc_add_frame_internal ffmpeg/libavfilter/buffersrc.c:261
    #10 0x86ebc2 in av_buffersrc_add_frame_flags ffmpeg/libavfilter/buffersrc.c:170:16
    #11 0x666867 in ifilter_send_frame ffmpeg/fftools/ffmpeg.c:2196:11
    #12 0x666867 in send_frame_to_filters ffmpeg/fftools/ffmpeg.c:2270
    #13 0x6075f7 in decode_video ffmpeg/fftools/ffmpeg.c:2469:11
    #14 0x6075f7 in process_input_packet ffmpeg/fftools/ffmpeg.c:2623
    #15 0x64ab67 in process_input ffmpeg/fftools/ffmpeg.c:4518:5
    #16 0x5e7157 in transcode_step ffmpeg/fftools/ffmpeg.c:4638:11
    #17 0x5e7157 in transcode ffmpeg/fftools/ffmpeg.c:4692
    #18 0x5db65b in main ffmpeg/fftools/ffmpeg.c:4894:9
    #19 0x7ffff5c93b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #20 0x41def9 in _start (ffmpeg/ffmpeg_g+0x41def9)

0x619000004470 is located 752 bytes inside of 1064-byte region [0x619000004180,0x6190000045a8)
freed by thread T0 here:
    #0 0x4ddbe0 in __interceptor_free.localalias.0 (ffmpeg/ffmpeg_g+0x4ddbe0)
    #1 0x1d67a88 in dump_stream_format ffmpeg/libavformat/dump.c:492:5
    #2 0x1d6571e in av_dump_format ffmpeg/libavformat/dump.c:659:13

previously allocated by thread T0 here:
    #0 0x4de9e8 in posix_memalign (ffmpeg/ffmpeg_g+0x4de9e8)
    #1 0x8564fb1 in av_malloc ffmpeg/libavutil/mem.c:87:9
    #2 0x46096ba in avcodec_alloc_context3 ffmpeg/libavcodec/options.c:158:28
    #3 0x1d6571e in av_dump_format ffmpeg/libavformat/dump.c:659:13

SUMMARY: AddressSanitizer: heap-use-after-free ffmpeg/libavfilter/vf_minterpolate.c:304:21 in get_sbad_ob

Please confirm.

Attachments (2)

gdb-vf_minterpolate_304 (16.9 KB ) - added by Suhwan 3 years ago.
PoC_vf_minterpolate_304.bmp (246 bytes ) - added by Suhwan 3 years ago.

Download all attachments as: .zip

Change History (4)

by Suhwan, 3 years ago

Attachment: gdb-vf_minterpolate_304 added

by Suhwan, 3 years ago

Attachment: PoC_vf_minterpolate_304.bmp added


comment:1 by mkver, 21 months ago

Component: undeterminedavfilter
Resolution: fixed
Status: newclosed

comment:2 by Carl Eugen Hoyos, 21 months ago

Keywords: minterpolate added
Note: See TracTickets for help on using tickets.