Skip to content

Commit 7c166dc

Browse files
GeorgNeismibrunin
authored andcommitted
[Backport] Security bug 1161847
Partial cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/v8/v8/+/2748077: Merged: Squashed multiple commits. Merged: [const-tracking] Mark const field as mutable when reconfiguring Revision: 7535b91f7cb22274de734d5da7d0324d8653d626 Merged: [const-tracking] Fix incorrect DCHECK in MapUpdater Revision: f95db8916a731e6e5ccc0282616bc907ce06012f BUG=chromium:1161847,chromium:1185463,v8:9233 NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true [email protected] Change-Id: I4a34bafb3b072f2e788b47949947c76110f1b85c Reviewed-by: Igor Sheludko <[email protected]> Commit-Queue: Georg Neis <[email protected]> Cr-Commit-Position: refs/branch-heads/9.0@{#18} Cr-Branched-From: bd0108b4c88e0d6f2350cb79b5f363fbd02f3eb7-refs/heads/9.0.257@{#1} Cr-Branched-From: 349bcc6a075411f1a7ce2d866c3dfeefc2efa39d-refs/heads/master@{#73001} Reviewed-by: Jüri Valdmann <[email protected]>
1 parent 30e481b commit 7c166dc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

chromium/v8/src/objects/map-updater.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,41 @@ Handle<Map> MapUpdater::ReconfigureToDataField(InternalIndex descriptor,
121121
PropertyDetails old_details =
122122
old_descriptors_->GetDetails(modified_descriptor_);
123123

124+
// If the {descriptor} was "const" data field so far, we need to update the
125+
// {old_map_} here, otherwise we could get the constants wrong, i.e.
126+
//
127+
// o.x = 1;
128+
// change o.x's attributes to something else
129+
// delete o.x;
130+
// o.x = 2;
131+
//
132+
// could trick V8 into thinking that `o.x` is still 1 even after the second
133+
// assignment.
134+
// This situation is similar to what might happen with property deletion.
135+
if (old_details.constness() == PropertyConstness::kConst &&
136+
old_details.location() == kField &&
137+
old_details.attributes() != new_attributes_) {
138+
Handle<FieldType> field_type(
139+
old_descriptors_->GetFieldType(modified_descriptor_), isolate_);
140+
Map::GeneralizeField(isolate_, old_map_, descriptor,
141+
PropertyConstness::kMutable,
142+
old_details.representation(), field_type);
143+
// The old_map_'s property must become mutable.
144+
// Note, that the {old_map_} and {old_descriptors_} are not expected to be
145+
// updated by the generalization if the map is already deprecated.
146+
DCHECK_IMPLIES(
147+
!old_map_->is_deprecated(),
148+
PropertyConstness::kMutable ==
149+
old_descriptors_->GetDetails(modified_descriptor_).constness());
150+
// Although the property in the old map is marked as mutable we still
151+
// treat it as constant when merging with the new path in transition tree.
152+
// This is fine because up until this reconfiguration the field was
153+
// known to be constant, so it's fair to proceed treating it as such
154+
// during this reconfiguration session. The issue is that after the
155+
// reconfiguration the original field might become mutable (see the delete
156+
// example above).
157+
}
158+
124159
// If property kind is not reconfigured merge the result with
125160
// representation/field type from the old descriptor.
126161
if (old_details.kind() == new_kind_) {

0 commit comments

Comments
 (0)