Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Issue 1571233003: Fix errors caused by unsafe conversions to/from size_t (Closed)

Created:
4 years, 11 months ago by Justin Novosad
Modified:
4 years, 11 months ago
Reviewers:
haraken
CC:
chromium-reviews, webcomponents-bugzilla_chromium.org, dshwang, fs, eric.carlson_apple.com, apavlov+blink_chromium.org, kinuko+watch, danakj+watch_chromium.org, rwlbuis, Yoav Weiss, pdr+graphicswatchlist_chromium.org, drott+blinkwatch_chromium.org, blink-reviews-css, blink-reviews-html_chromium.org, Justin Novosad, blink-reviews-platform-graphics_chromium.org, dglazkov+blink, Rik, blink-reviews-bindings_chromium.org, gavinp+loader_chromium.org, loading-reviews_chromium.org, nessy, vmpstr+blinkwatch_chromium.org, blink-reviews-wtf_chromium.org, philipj_slow, jbroman, blink-reviews, krit, darktears, loading-reviews+fetch_chromium.org, Nate Chapin, vcarbune.chromium, michaeln, tyoshino+watch_chromium.org, tfarina, gasubic, f(malita), Stephen Chennney, Mikhail
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix errors caused by unsafe conversions to/from size_t The real world error this CL fixes is in initCSSFontFace where allocating a buffer with a size between 2G and 4G would cause an unsigned to int conversion that overflowed into the sign bit. While investigating this issue, many other unsafe cast were found and are fixed by this change. SharedBuffer was changed to use size_t consistently and a new intrumentation pattern was implemented to prevent call sites of SharedBuffer from performing unsafe casts. The underlying issue is a rabbit hole, and this CL does not propagate all the way through (which would be an unmanageably large patch). At the far reaches of this change some unsafe casts were kept (ex. int to size_t), but the safety of those casts was mitigated by adding run-time checks, implemented by using safeCast<size_t>. The check in safeCast<T> was changed from ASSERT to RELEASE_ASSERT to better protect against potential security vulnerabilities. The reasoning is that many of the values that pass through safeCast are buffer sizes or array indices, so bad casts may lead to memory access errors. When this situation is encountered we prefer to intentionally crash the process. BUG=474899 Committed: https://crrev.com/4b510033b7c3286e244d38351d2a8868c5e6a7b6 Cr-Commit-Position: refs/heads/master@{#368890}

Patch Set 1 #

Patch Set 2 : win build fix #

Patch Set 3 : improved ALLOW_NUMERIC_ARG_TYPES_PROMOTABLE_TO #

Unified diffs Side-by-side diffs Delta from patch set Stats (+220 lines, -153 lines) Patch
M third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp View 5 chunks +8 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/css/FontFace.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/css/FontFace.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/ImageResource.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/ImageResource.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/RawResource.h View 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/RawResource.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/RawResourceTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/Resource.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/Resource.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/ScriptResource.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/ScriptResource.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fetch/TextResource.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/imports/HTMLImportLoader.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/imports/HTMLImportLoader.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/track/vtt/VTTParser.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/track/vtt/VTTParser.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentLoader.h View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentLoader.cpp View 3 chunks +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h View 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp View 2 chunks +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/loader/TextTrackLoader.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/TextTrackLoader.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/xml/parser/SharedBufferReader.h View 1 chunk +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/xml/parser/SharedBufferReader.cpp View 2 chunks +6 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/SharedBuffer.h View 4 chunks +57 lines, -14 lines 0 comments Download
M third_party/WebKit/Source/platform/SharedBuffer.cpp View 12 chunks +44 lines, -52 lines 0 comments Download
M third_party/WebKit/Source/platform/SharedBufferTest.cpp View 5 chunks +6 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/FastSharedBufferReader.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/FastSharedBufferReader.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp View 2 chunks +5 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/ImageDecoderTestHelpers.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp View 2 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp View 5 chunks +7 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp View 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/wtf/StdLibExtras.h View 1 2 1 chunk +31 lines, -1 line 0 comments Download

Depends on Patchset:

Messages

Total messages: 10 (5 generated)
Justin Novosad
PTAL
4 years, 11 months ago (2016-01-11 18:30:31 UTC) #2
haraken
LGTM
4 years, 11 months ago (2016-01-11 23:56:12 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1571233003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1571233003/40001
4 years, 11 months ago (2016-01-12 15:37:31 UTC) #6
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 11 months ago (2016-01-12 16:20:33 UTC) #8
commit-bot: I haz the power
4 years, 11 months ago (2016-01-12 16:21:54 UTC) #10
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/4b510033b7c3286e244d38351d2a8868c5e6a7b6
Cr-Commit-Position: refs/heads/master@{#368890}

Powered by Google App Engine
This is Rietveld 408576698