New issue
Advanced search Search tips

Issue 681311 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 1
Type: Bug

Blocking:
issue 62400



Sign in to add a comment

Out-of-memory in pdf_codec_tiff_fuzzer

Project Member Reported by ClusterFuzz, Jan 14 2017

Issue description

Components: Internals>Plugins>PDF
Labels: Test-Predator-Wrong M-56
Owner: dsinclair@chromium.org
Status: Assigned (was: Untriaged)
As per  issue 672178 , assigning to dsinclair@. could you please take a look?
Thank you.
Blocking: 62400
Labels: -M-56
TIFF is XFA code, XFA is not enabled for any branch of chrome.

Comment 3 by npm@chromium.org, Jan 19 2017

I looked at this a bit. It looks like libtiff is just allocating a lot of memory from TIFFReadDirEntryArray because |direntry| lies about its |tdir_count| and then we have:
*count=(uint32)direntry->tdir_count;
datasize=(*count)*typesize;
data=_TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray");

There is also a basic sanity check regarding the dimensions, and we don't want to be more strict with that. So not much we can do as far as I can tell.
Project Member

Comment 5 by ClusterFuzz, Feb 28 2017

Labels: ClusterFuzz-Verified
Status: Verified (was: Assigned)
ClusterFuzz testcase 6307227796504576 is verified as fixed, so closing issue.

If this is incorrect, please add ClusterFuzz-Wrong label and re-open the issue.

Comment 6 by npm@chromium.org, Mar 1 2017

Labels: -ClusterFuzz-Verified
Status: Assigned (was: Verified)
Owner: npm@chromium.org
This doesn't repro for me, npm@ can you give it a try.

Comment 8 by npm@chromium.org, Mar 28 2017

It reproduces for me. But the cause is a big malloc in libtiff[1]. WontFix or WDYT?

[1] https://cs.chromium.org/chromium/src/third_party/pdfium/third_party/libtiff/tif_dirread.c?type=cs&q=tif_dirread.c:793&l=793

Comment 9 by npm@chromium.org, Mar 28 2017

Status: Started (was: Assigned)
Project Member

Comment 10 by bugdroid1@chromium.org, Mar 29 2017

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium/+/47b8f070dc11308e0bef3a157f6c70fbcad4093a

commit 47b8f070dc11308e0bef3a157f6c70fbcad4093a
Author: Nicolas Pena <npm@chromium.org>
Date: Wed Mar 29 19:20:57 2017

Do more checks before big allocs in TIFFReadDirEntryArray

This CL fixes the only caller to TIFFReadDirEntryData with potentially large
size so that we avoid big mallocs when we know we will fail. It does this as
follows:
- Avoid the unnecessary computations if datasize is very small. We don't want
to be slower in this case.
- If !isMapped(tif), we will Seek and Read. Check that ending position is
reachable. In the other case, do a simple check for out of bounds.

Bug:  chromium:681311 
Change-Id: Ia172d8b4d401753b7c8d5455dc1ada5335f6fa6b
Reviewed-on: https://pdfium-review.googlesource.com/3253
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>

[modify] https://crrev.com/47b8f070dc11308e0bef3a157f6c70fbcad4093a/third_party/libtiff/tif_dirread.c
[modify] https://crrev.com/47b8f070dc11308e0bef3a157f6c70fbcad4093a/third_party/libtiff/README.pdfium
[add] https://crrev.com/47b8f070dc11308e0bef3a157f6c70fbcad4093a/third_party/libtiff/0019-oom-TIFFReadDirEntryArray.patch

Comment 11 by npm@chromium.org, Mar 29 2017

Status: Fixed (was: Started)
Upstream bug filed: http://bugzilla.maptools.org/show_bug.cgi?id=2675
Project Member

Comment 12 by ClusterFuzz, Mar 30 2017

Project Member

Comment 13 by bugdroid1@chromium.org, Jun 26 2017

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium/+/cbe6d1662e2b76a343702fc77334f6e68b854427

commit cbe6d1662e2b76a343702fc77334f6e68b854427
Author: Nicolas Pena <npm@chromium.org>
Date: Mon Jun 26 19:22:32 2017

Add comment in libtiff patch

This CL adds a comment to point to the upstream bug of a patch fixing
an OOM. The fix is fine for us but not accepted upstream so it should
be ignored once upstream fixes the bug.

Bug:  chromium:681311 
Change-Id: I6986fb7c851e260e84f764449ff1ee46441e71b4
Reviewed-on: https://pdfium-review.googlesource.com/6953
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>

[modify] https://crrev.com/cbe6d1662e2b76a343702fc77334f6e68b854427/third_party/libtiff/README.pdfium

Sign in to add a comment