Bug 156780 - bmalloc: fix up overflow checks
Summary: bmalloc: fix up overflow checks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: bmalloc (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-19 20:09 PDT by Geoffrey Garen
Modified: 2016-04-20 11:04 PDT (History)
2 users (show)

See Also:


Attachments
Patch (7.00 KB, patch)
2016-04-19 20:12 PDT, Geoffrey Garen
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2016-04-19 20:09:49 PDT
bmalloc: fix up overflow checks
Comment 1 Geoffrey Garen 2016-04-19 20:12:50 PDT
Created attachment 276795 [details]
Patch
Comment 2 Mark Lam 2016-04-19 20:56:11 PDT
Comment on attachment 276795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=276795&action=review

r=me

> Source/bmalloc/ChangeLog:11
> +        we were missing smoe cases.

typo: /smoe/some/.
Comment 3 Mark Lam 2016-04-19 20:57:04 PDT
Comment on attachment 276795 [details]
Patch

Is it possible to add some tests that exercise the overflow cases?
Comment 4 Geoffrey Garen 2016-04-19 21:12:50 PDT
> Is it possible to add some tests that exercise the overflow cases?

Good question. This requires some changes to the MallocBench infrastructure to allow for failure. I'll tackle this in a follow-up patch.
Comment 5 Geoffrey Garen 2016-04-19 21:13:43 PDT
Committed r199759: <http://trac.webkit.org/changeset/199759>
Comment 6 Oliver Hunt 2016-04-20 10:34:56 PDT
Comment on attachment 276795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=276795&action=review

> Source/bmalloc/bmalloc/Heap.cpp:347
> +    size_t roundedSize = size ? roundUpToMultipleOf(largeAlignment, size) : largeAlignment;

I wonder if we should make an override for roundUp... to take Checked<T> - then switch to Checked<> for bmalloc internal arithmetic?
Comment 7 Geoffrey Garen 2016-04-20 11:04:37 PDT
> > Source/bmalloc/bmalloc/Heap.cpp:347
> > +    size_t roundedSize = size ? roundUpToMultipleOf(largeAlignment, size) : largeAlignment;
> 
> I wonder if we should make an override for roundUp... to take Checked<T> -
> then switch to Checked<> for bmalloc internal arithmetic?

I'd like to come up with a good idiom, maybe using builtin checked arithmetic. Not sure what the best option is.