Bug 2683 - libtiff:memory allocation failed in tiff2pdf.c:808
: libtiff:memory allocation failed in tiff2pdf.c:808
Status: RESOLVED LATER
: libtiff
default
: unspecified
: PC Linux
: P1 normal
: ---
Assigned To:
:
:
: migrated_to_gitlab
:
:
  Show dependency treegraph
 
Reported: 2017-04-20 00:58 by
Modified: 2019-10-01 14:20 (History)


Attachments
testcase (914.57 KB, image/tiff)
2017-04-20 00:58, bestshow
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2017-04-20 00:58:26
Created an attachment (id=764) [details]
testcase

on libtiff 4.0.7

A memory allocation failed was found in tiff2pdf.c:808  which allows attackers
to cause a denial of service via a crafted file.

tiff2pdf $FILE -o out.pdf

failed to allocate
==8088==ERROR: AddressSanitizer failed to allocate 0x7800e3000 (32213184512)
bytes of LargeMmapAllocator (error code: 12)
==8088==Process memory map follows:
    0x000000400000-0x000000548000   
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7_build/bin/tiff2pdf
    0x000000747000-0x000000748000   
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7_build/bin/tiff2pdf
    0x000000748000-0x000000760000   
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7_build/bin/tiff2pdf
    0x00007fff7000-0x00008fff7000   
    0x00008fff7000-0x02008fff7000   
    0x02008fff7000-0x10007fff8000   
    0x600000000000-0x602000000000   
    0x602000000000-0x602000010000   
    0x602000010000-0x603000000000   
    0x603000000000-0x603000010000   
    0x603000010000-0x604000000000   
    0x604000000000-0x604000010000   
    0x604000010000-0x606000000000   
    0x606000000000-0x606000010000   
    0x606000010000-0x60c000000000   
    0x60c000000000-0x60c000010000   
    0x60c000010000-0x611000000000   
    0x611000000000-0x611000010000   
    0x611000010000-0x615000000000   
    0x615000000000-0x615000020000   
    0x615000020000-0x616000000000   
    0x616000000000-0x616000020000   
    0x616000020000-0x619000000000   
    0x619000000000-0x619000020000   
    0x619000020000-0x61a000000000   
    0x61a000000000-0x61a000020000   
    0x61a000020000-0x61d000000000   
    0x61d000000000-0x61d000020000   
    0x61d000020000-0x61f000000000   
    0x61f000000000-0x61f000020000   
    0x61f000020000-0x624000000000   
    0x624000000000-0x624000020000   
    0x624000020000-0x631000000000   
    0x631000000000-0x631000030000   
    0x631000030000-0x640000000000   
    0x640000000000-0x640000003000   
    0x7f53752f4000-0x7f5376100000   
    0x7f5376200000-0x7f5376300000   
    0x7f53763e1000-0x7f5378733000   
    0x7f5378733000-0x7f5378749000    /usr/local/lib64/libgcc_s.so.1
    0x7f5378749000-0x7f5378948000    /usr/local/lib64/libgcc_s.so.1
    0x7f5378948000-0x7f5378949000    /usr/local/lib64/libgcc_s.so.1
    0x7f5378949000-0x7f537894a000    /usr/local/lib64/libgcc_s.so.1
    0x7f537894a000-0x7f5378abb000   
/home/haojun/Downloads/software/gcc-6.3.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.22
    0x7f5378abb000-0x7f5378cbb000   
/home/haojun/Downloads/software/gcc-6.3.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.22
    0x7f5378cbb000-0x7f5378cc5000   
/home/haojun/Downloads/software/gcc-6.3.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.22
    0x7f5378cc5000-0x7f5378cc7000   
/home/haojun/Downloads/software/gcc-6.3.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.22
    0x7f5378cc7000-0x7f5378ccb000   
    0x7f5378ccb000-0x7f5378ce2000    /usr/lib64/libpthread-2.17.so
    0x7f5378ce2000-0x7f5378ee1000    /usr/lib64/libpthread-2.17.so
    0x7f5378ee1000-0x7f5378ee2000    /usr/lib64/libpthread-2.17.so
    0x7f5378ee2000-0x7f5378ee3000    /usr/lib64/libpthread-2.17.so
    0x7f5378ee3000-0x7f5378ee7000   
    0x7f5378ee7000-0x7f5378eee000    /usr/lib64/librt-2.17.so
    0x7f5378eee000-0x7f53790ed000    /usr/lib64/librt-2.17.so
    0x7f53790ed000-0x7f53790ee000    /usr/lib64/librt-2.17.so
    0x7f53790ee000-0x7f53790ef000    /usr/lib64/librt-2.17.so
    0x7f53790ef000-0x7f53790f1000    /usr/lib64/libdl-2.17.so
    0x7f53790f1000-0x7f53792f1000    /usr/lib64/libdl-2.17.so
    0x7f53792f1000-0x7f53792f2000    /usr/lib64/libdl-2.17.so
    0x7f53792f2000-0x7f53792f3000    /usr/lib64/libdl-2.17.so
    0x7f53792f3000-0x7f53794a9000    /usr/lib64/libc-2.17.so
    0x7f53794a9000-0x7f53796a9000    /usr/lib64/libc-2.17.so
    0x7f53796a9000-0x7f53796ad000    /usr/lib64/libc-2.17.so
    0x7f53796ad000-0x7f53796af000    /usr/lib64/libc-2.17.so
    0x7f53796af000-0x7f53796b4000   
    0x7f53796b4000-0x7f53797b4000    /usr/lib64/libm-2.17.so
    0x7f53797b4000-0x7f53799b4000    /usr/lib64/libm-2.17.so
    0x7f53799b4000-0x7f53799b5000    /usr/lib64/libm-2.17.so
    0x7f53799b5000-0x7f53799b6000    /usr/lib64/libm-2.17.so
    0x7f53799b6000-0x7f53799cb000    /usr/lib64/libz.so.1.2.7
    0x7f53799cb000-0x7f5379bca000    /usr/lib64/libz.so.1.2.7
    0x7f5379bca000-0x7f5379bcb000    /usr/lib64/libz.so.1.2.7
    0x7f5379bcb000-0x7f5379bcc000    /usr/lib64/libz.so.1.2.7
    0x7f5379bcc000-0x7f5379c0f000    /usr/lib64/libjpeg.so.62.1.0
    0x7f5379c0f000-0x7f5379e0f000    /usr/lib64/libjpeg.so.62.1.0
    0x7f5379e0f000-0x7f5379e10000    /usr/lib64/libjpeg.so.62.1.0
    0x7f5379e10000-0x7f5379e11000    /usr/lib64/libjpeg.so.62.1.0
    0x7f5379e11000-0x7f5379e21000   
    0x7f5379e21000-0x7f5379e46000    /usr/lib64/liblzma.so.5.2.2
    0x7f5379e46000-0x7f537a045000    /usr/lib64/liblzma.so.5.2.2
    0x7f537a045000-0x7f537a046000    /usr/lib64/liblzma.so.5.2.2
    0x7f537a046000-0x7f537a047000    /usr/lib64/liblzma.so.5.2.2
    0x7f537a047000-0x7f537a16a000    /usr/local/lib/libasan.so.3
    0x7f537a16a000-0x7f537a36a000    /usr/local/lib/libasan.so.3
    0x7f537a36a000-0x7f537a36d000    /usr/local/lib/libasan.so.3
    0x7f537a36d000-0x7f537a370000    /usr/local/lib/libasan.so.3
    0x7f537a370000-0x7f537afe2000   
    0x7f537afe2000-0x7f537b002000    /usr/lib64/ld-2.17.so
    0x7f537b013000-0x7f537b043000   
    0x7f537b043000-0x7f537b0c6000   
    0x7f537b0c6000-0x7f537b1ab000   
/home/haojun/Downloads/imagetemplate/zzuftest_tif/1348-pc260001.tif
    0x7f537b1ab000-0x7f537b1e8000   
    0x7f537b1e8000-0x7f537b201000   
    0x7f537b201000-0x7f537b202000    /usr/lib64/ld-2.17.so
    0x7f537b202000-0x7f537b203000    /usr/lib64/ld-2.17.so
    0x7f537b203000-0x7f537b204000   
    0x7ffee8906000-0x7ffee8927000    [stack]
    0x7ffee89e2000-0x7ffee89e4000    [vdso]
    0xffffffffff600000-0xffffffffff601000    [vsyscall]
==8088==End of process memory map.
==8088==AddressSanitizer CHECK failed:
../../../../libsanitizer/sanitizer_common/sanitizer_common.cc:180 "((0 &&
"unable to mmap")) != (0)" (0x0, 0x0)
    #0 0x7f537a111d4d in AsanCheckFailed
../../../../libsanitizer/asan/asan_rtl.cc:65
    #1 0x7f537a117993 in __sanitizer::CheckFailed(char const*, int, char
const*, unsigned long long, unsigned long long)
../../../../libsanitizer/sanitizer_common/sanitizer_common.cc:157
    #2 0x7f537a117b7d in __sanitizer::ReportMmapFailureAndDie(unsigned long,
char const*, char const*, int)
../../../../libsanitizer/sanitizer_common/sanitizer_common.cc:180
    #3 0x7f537a121582 in __sanitizer::MmapOrDie(unsigned long, char const*)
../../../../libsanitizer/sanitizer_common/sanitizer_posix.cc:120
    #4 0x7f537a06c40d in
__sanitizer::LargeMmapAllocator<__asan::AsanMapUnmapCallback>::Allocate(__sanitizer::AllocatorStats*,
unsigned long, unsigned long)
../../../../libsanitizer/sanitizer_common/sanitizer_allocator.h:1031
    #5 0x7f537a06c40d in
__sanitizer::CombinedAllocator<__sanitizer::SizeClassAllocator64<105553116266496ul,
4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>,
__asan::AsanMapUnmapCallback>,
__sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator64<105553116266496ul,
4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>,
__asan::AsanMapUnmapCallback> >,
__sanitizer::LargeMmapAllocator<__asan::AsanMapUnmapCallback>
>::Allocate(__sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator64<105553116266496ul,
4398046511104ul, 0ul, __sanitizer::SizeClassMap<17ul, 128ul, 16ul>,
__asan::AsanMapUnmapCallback> >*, unsigned long, unsigned long, bool, bool)
../../../../libsanitizer/sanitizer_common/sanitizer_allocator.h:1300
    #6 0x7f537a06c40d in __asan::Allocator::Allocate(unsigned long, unsigned
long, __sanitizer::BufferedStackTrace*, __asan::AllocType, bool)
../../../../libsanitizer/asan/asan_allocator.cc:366
    #7 0x7f537a06c40d in __asan::asan_malloc(unsigned long,
__sanitizer::BufferedStackTrace*)
../../../../libsanitizer/asan/asan_allocator.cc:716
    #8 0x7f537a108b95 in __interceptor_malloc
../../../../libsanitizer/asan/asan_malloc_linux.cc:63
    #9 0x507dd3 in _TIFFmalloc
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/libtiff/tif_unix.c:316
    #10 0x40fbab in t2p_readwrite_pdf_image
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiff2pdf.c:2445
    #11 0x42c71c in t2p_write_pdf
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiff2pdf.c:5549
    #12 0x404386 in main
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiff2pdf.c:808
    #13 0x7f5379314b34 in __libc_start_main (/lib64/libc.so.6+0x21b34)
    #14 0x402b28 
(/home/haojun/Downloads/testopensourcecode/tiff-4.0.7_build/bin/tiff2pdf+0x402b28)

testcase:https://github.com/bestshow/p0cs/blob/master/allocate-failed-in-tiff2pdf.tif
------- Comment #1 From 2019-10-01 14:20:16 -------
Bugzilla is no longer used for tracking libtiff issues. Remaining open tickets,
such as this one, have been migrated to the libtiff GitLab instance at
https://gitlab.com/libtiff/libtiff/issues .

The migrated tickets have their summary prefixed with [BZ#XXXX] where XXXX is
the initial Bugzilla issue number.