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

Issue 1582023: Apply a sanity limit to objects with width & height. (Closed)

Created:
10 years, 8 months ago by Chris Evans
Modified:
9 years, 6 months ago
CC:
chromium-reviews
Base URL:
svn://chrome-svn.corp.google.com/chrome/trunk/src/
Visibility:
Public.

Description

Apply a sanity limit to objects with width & height. TEST=NONE BUG=NONE Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=45797

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -0 lines) Patch
M chrome/common/common_param_traits.cc View 1 2 2 chunks +5 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Chris Evans
Defense in depth...
10 years, 8 months ago (2010-04-11 04:03:15 UTC) #1
cevans
Hang fire on this one Justin. I want to make sure "width + start position" ...
10 years, 8 months ago (2010-04-11 07:50:21 UTC) #2
Chris Evans
Ok. Now with more thorough validation. Ready for review.
10 years, 8 months ago (2010-04-12 15:07:56 UTC) #3
jschuh
I'm very confused, because I haven't followed this particular code path. It looks like wraps ...
10 years, 8 months ago (2010-04-12 16:56:56 UTC) #4
cevans
Thanks for the schooling :) Inline: On Mon, Apr 12, 2010 at 9:56 AM, <jschuh@chromium.org> ...
10 years, 8 months ago (2010-04-15 09:41:55 UTC) #5
jschuh
I swear, I'm not trying to be difficult... On 2010/04/15 09:41:55, cevans_google.com wrote: > I ...
10 years, 8 months ago (2010-04-16 05:18:31 UTC) #6
cevans
On Thu, Apr 15, 2010 at 10:18 PM, <jschuh@chromium.org> wrote: > I swear, I'm not ...
10 years, 8 months ago (2010-04-18 20:51:18 UTC) #7
DO NOT USE (jschuh)
10 years, 8 months ago (2010-04-20 18:42:34 UTC) #8
Fair enough. LGTM.

On 2010/04/18 20:51:18, cevans_google.com wrote:
> On Thu, Apr 15, 2010 at 10:18 PM, <mailto:jschuh@chromium.org> wrote:
> 
> > I swear, I'm not trying to be difficult...
> 
> 
> Thorough reviews encouraged :)
> 
> 
> >
> > On 2010/04/15 09:41:55, http://cevans_google.com wrote:
> >
> >> I prefer to check the natural types in this case. Feels cleaner than
> >> casting. Let me know if you have a strong opinion and I can change it.
> >>
> >
> > I'd probably use something like the following:
> >
> > #define COORD_MAX (1 << 15)
> > #define BAD_COORD_MASK (~(COORD_MAX - 1))
> >
> > ...
> >
> >  if ((x | y | w | h | (x + w) | (y + h)) & BAD_COORD_MASK)
> >    return false;
> >
> > ...
> >
> >  if ((w | h) & BAD_COORD_MASK)
> >    return false;
> >
> 
> Ugh! re: this paradigm. It takes me several readings to understand this all,
> which is bad for a security check. My brain wants to work in terms of max
> and min values. Not bitmasks...
> 
> 
> >
> > Here's my reasoning. You know that you're going to cap each dimension at
> > 32768
> > because that's where Skia and other graphics libs cap int coords.
> 
> 
> Hmm - do we really never handle > 32767? What about a 100000x10 PNG? (A wide
> but manageable amount of data). I must admit, I just created such a PNG and
> it loads without error but does not seem to display anything. I'd like
> independent confirmation before I go capping a dimension that low. And for
> safety, I probably prefer a more conservative approach such as my most
> recent proposal...
> 
> (And even if
> > the cap is larger in the future, it will always be a power of two narrower
> > than
> > half a native word.) So, bit operations are cleaner and a lot faster, which
> > strikes me as important in a graphics path.
> 
> 
> This is a deserialization path. We likely just took a context switch plus a
> syscall to read from a pipe. Counting cycles doesn't seem productive in this
> code path.
> 
> Cheers
> Chris
> 
> 
> >
> >
> >  Yeah. This is a nice centralized, low-level check to reject clearly crazy
> >> rects and sizes as a defense-in-depth measure. If someone starts doing
> >> matrix transforms on their rects, they will need to adopt their own
> >> additional validation :)
> >>
> >
> > I guess that makes sense, but I'm just wondering if there's somewhere else
> > we
> > should be checking. Guess I'll poke around at the code when I get some free
> > time.
> >
> >
> >
> > http://codereview.chromium.org/1582023/show
> >
>

Powered by Google App Engine
This is Rietveld 408576698