New issue
Advanced search Search tips

Issue 654365 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Direct-leak in CJBig2_Image::subImage

Project Member Reported by ClusterFuzz, Oct 10 2016

Issue description

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=6645639570259968

Fuzzer: libfuzzer_pdf_codec_jbig2_fuzzer
Job Type: libfuzzer_chrome_asan
Platform Id: linux

Crash Type: Direct-leak
Crash Address: 
Crash State:
  CJBig2_Image::subImage
  CJBig2_SDDProc::decode_Huffman
  CJBig2_Context::parseSymbolDict
  
Regressed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_asan&range=424084:424087

Minimized Testcase (0.05 Kb): https://cluster-fuzz.appspot.com/download/AMIfv94ytpm9CilAFgTTPmOun4vDDERDWBmrXtDdqzZZ3AMII6-gjUfHn-zR29RSz-icg76nHdC1BNabb5LIY9D8_hXEpZZtVtdlnAv1EO6D4K2dDkpsAkBh2WDf8GL4hWIj5VuW4H1-gHaEJNljK5HzthENJBatcA?testcase_id=6645639570259968

Issue manually filed by: nyerramilli

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md for more information.
 
Cc: nyerramilli@chromium.org brucedaw...@chromium.org
Components: Tools>Test>FindIt>WrongResult Internals>Plugins>PDF
Labels: findit-wrong Te-Logged
Owner: dsinclair@chromium.org
Status: Assigned (was: Untriaged)
Providing Findit results for internal purpose:
Suspected CLs	Git blame below is NOT necessarily who introduced the crash nor the owner for it. Please check the code before assigning to anyone.(No CL in the regression range changed the crashing files.)

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 183 of file JBig2_Image.cpp, which is stack frame 1.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 546 of file JBig2_SddProc.cpp, which is stack frame 2.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 614 of file JBig2_Context.cpp, which is stack frame 3.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 339 of file JBig2_Context.cpp, which is stack frame 4.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 330 of file JBig2_Context.cpp, which is stack frame 5.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 86 of file JBig2_Context.cpp, which is stack frame 6.

Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 189 of file JBig2_Context.cpp, which is stack frame 7.

Suspected Project: chromium-pdfium

requesting pdfium team to check the issue.
Cc: kcwu@chromium.org
It looks like the code fails to cleanup the SDNEWSYMS array correctly. In jBig2_SddProc.cpp we allocate a number of BHC->subImage's and put them into SDNEWSYMS.

In this case we create 20 subimages. We then set EXFLAGS to true for images 0-1, 11-19.

We then either add the image to pDict for free it. But we only free it if EXFLAGS is not true. So, we fail to free the 11 subimages we'd set EXFLAGS to true for.

I don't know what EXFLAGS means, or why we'd set it for those particular images.
Status: Started (was: Assigned)
Cc: -brucedaw...@chromium.org tsepez@chromium.org
Many of the VARIABLENAMES are directly from the JBIG2 spec, which describes the procedures PDFium implements. As with many specs, the spec does not deal with the corner cases.
Isn't SDNUMEXSYMS assigned on line 450 of JBig2_Context.cpp?

Comment 9 by kcwu@chromium.org, Oct 12 2016

Ah, you are right.
Project Member

Comment 10 by bugdroid1@chromium.org, Oct 13 2016

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium.git/+/6e5239c6e3891d78e7b9e8262c23cd129f0cdbb7

commit 6e5239c6e3891d78e7b9e8262c23cd129f0cdbb7
Author: dsinclair <dsinclair@chromium.org>
Date: Thu Oct 13 14:54:09 2016

Verify number of ex flags matches number of ex items.

Currently the JBig2 decoder can leak subimages in the case where we mark
more items in EXFLAGS then we have SDNUMEXSYMS. This Cl checks for this
condition and fails the decode if it happens.

BUG= chromium:654365 

Review-Url: https://codereview.chromium.org/2419553002

[modify] https://crrev.com/6e5239c6e3891d78e7b9e8262c23cd129f0cdbb7/core/fxcodec/jbig2/JBig2_SddProc.cpp

Status: Fixed (was: Started)
Project Member

Comment 12 by bugdroid1@chromium.org, Oct 13 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7f9206f34e7fba79d9b5ba24647f32e5c0431cfa

commit 7f9206f34e7fba79d9b5ba24647f32e5c0431cfa
Author: pdfium-deps-roller <pdfium-deps-roller@chromium.org>
Date: Thu Oct 13 15:56:21 2016

Roll src/third_party/pdfium/ f2b940ce2..6e5239c6e (2 commits).

https://pdfium.googlesource.com/pdfium.git/+log/f2b940ce281a..6e5239c6e389

$ git log f2b940ce2..6e5239c6e --date=short --no-merges --format='%ad %ae %s'
2016-10-13 dsinclair Verify number of ex flags matches number of ex items.
2016-10-13 dsinclair Cleanup CPDFXFA_App methods

BUG= 654365 

TBR=dsinclair@chromium.org

Review-Url: https://codereview.chromium.org/2416933002
Cr-Commit-Position: refs/heads/master@{#425047}

[modify] https://crrev.com/7f9206f34e7fba79d9b5ba24647f32e5c0431cfa/DEPS

Components: -Tools>Test>FindIt>WrongResult
Labels: Test-Predator-Wrong
Project Member

Comment 14 by sheriffbot@chromium.org, Nov 22 2016

Labels: -Restrict-View-EditIssue
Removing EditIssue view restrictions from ClusterFuzz filed bugs. If you believe that this issue should still be restricted, please reapply the label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment