Skip to content

Commit bc38ef7

Browse files
GeorgNeismibrunin
authored andcommitted
[Backport] CVE-2021-21227: Insufficient data validation in V8
Cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/v8/v8/+/2839559: Merged: [compiler] Fix a bug in VisitSpeculativeIntegerAdditiveOp Revision: 9313c4ce3f32ad81df1c65becccec7e129181ce3 BUG=chromium:1199345 NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true [email protected] Change-Id: I0ee9f13815b1a7d248d4caa506c6930697e1866c Commit-Queue: Georg Neis <[email protected]> Reviewed-by: Nico Hartmann <[email protected]> Cr-Commit-Position: refs/branch-heads/9.0@{#41} Cr-Branched-From: bd0108b4c88e0d6f2350cb79b5f363fbd02f3eb7-refs/heads/9.0.257@{#1} Cr-Branched-From: 349bcc6a075411f1a7ce2d866c3dfeefc2efa39d-refs/heads/master@{#73001} Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent 68da9a7 commit bc38ef7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

chromium/v8/src/compiler/simplified-lowering.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,10 +1318,15 @@ class RepresentationSelector {
13181318
Type right_feedback_type = TypeOf(node->InputAt(1));
13191319

13201320
// Using Signed32 as restriction type amounts to promising there won't be
1321-
// signed overflow. This is incompatible with relying on a Word32
1322-
// truncation in order to skip the overflow check.
1321+
// signed overflow. This is incompatible with relying on a Word32 truncation
1322+
// in order to skip the overflow check. Similarly, we must not drop -0 from
1323+
// the result type unless we deopt for -0 inputs.
13231324
Type const restriction =
1324-
truncation.IsUsedAsWord32() ? Type::Any() : Type::Signed32();
1325+
truncation.IsUsedAsWord32()
1326+
? Type::Any()
1327+
: (truncation.identify_zeros() == kIdentifyZeros)
1328+
? Type::Signed32OrMinusZero()
1329+
: Type::Signed32();
13251330

13261331
// Handle the case when no int32 checks on inputs are necessary (but
13271332
// an overflow check is needed on the output). Note that we do not

0 commit comments

Comments
 (0)