Skip to content

Wpe 2.38 backport hardening add bounds check to string view operator#1673

Open
aoikonomopoulos wants to merge 5 commits intoWebPlatformForEmbedded:wpe-2.38from
aoikonomopoulos:wpe-2.38-backport-Hardening-Add-bounds-check-to-StringView-operator
Open

Wpe 2.38 backport hardening add bounds check to string view operator#1673
aoikonomopoulos wants to merge 5 commits intoWebPlatformForEmbedded:wpe-2.38from
aoikonomopoulos:wpe-2.38-backport-Hardening-Add-bounds-check-to-StringView-operator

Conversation

@aoikonomopoulos
Copy link
Copy Markdown

@aoikonomopoulos aoikonomopoulos commented May 7, 2026

Pull Request Template

File a Bug

All changes should be associated with a bug. The WebKit project is currently using Bugzilla as our bug tracker. Note that multiple changes may be associated with a single bug.

Provided Tooling

The WebKit Project strongly recommends contributors use Tools/Scripts/git-webkit to generate pull requests. See Setup and Contributing Code for how to do this.

Template

If a contributor wishes to file a pull request manually, the template is below. Manually-filed pull requests should contain their commit message as the pull request description, and their commit message should be formatted like the template below.

Additionally, the pull request should be mentioned on Bugzilla, labels applied to the pull request matching the component and version of the Bugzilla associated with the pull request and the pull request assigned to its author.

< bug title >
https://bugs.webkit.org/show_bug.cgi?id=#####

Reviewed by NOBODY (OOPS!).

Explanation of why this fixes the bug (OOPS!).

* path/changed.ext:
(function):
(class.function):

b3f3ddf

Build-Tests Layout-Tests
✅ 🛠 wpe-238-amd64-build ✅ 🧪 wpe-238-amd64-layout
✅ 🛠 wpe-238-arm32-build ✅ 🧪 wpe-238-arm32-layout

aoikonomopoulos and others added 5 commits May 7, 2026 09:07
…g/show_bug.cgi?id=244903 rdar://99644213

Reviewed by Alexey Shvayka and Justin Michaud.

According to the spec[1], TypedArray has an ability to stop [[Prototype]] traversing for numeric index string (e.g. "0.1").
Thus we should align IC's traversing to this behavior, which is already implemented in JSObject::getPropertySlot.
This patch threads property name and we check this abruption in prototype traversing code for IC if structure is TypedArray.

[1]: https://262.ecma-international.org/9.0/#_ref_2826

* JSTests/stress/poly-proto-typed-array-case.js: Added.
(bar.Foo):
(bar):
* Source/JavaScriptCore/bytecode/ObjectPropertyConditionSet.cpp:
(JSC::generateConditionsForPropertyMiss):
(JSC::generateConditionsForPropertySetterMiss):
(JSC::generateConditionsForIndexedMiss):
(JSC::generateConditionsForPrototypePropertyHit):
(JSC::generateConditionsForPrototypePropertyHitCustom):
(JSC::generateConditionsForInstanceOf):
(JSC::generateConditionsForPrototypeEquivalenceConcurrently):
(JSC::generateConditionsForPropertyMissConcurrently):
(JSC::generateConditionsForPropertySetterMissConcurrently):
(JSC::prepareChainForCaching):
* Source/JavaScriptCore/bytecode/ObjectPropertyConditionSet.h:
* Source/JavaScriptCore/bytecode/PolyProtoAccessChain.cpp:
(JSC::PolyProtoAccessChain::tryCreate):
* Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h:
* Source/JavaScriptCore/bytecode/Repatch.cpp:
(JSC::tryCacheGetBy):
(JSC::tryCacheArrayGetByVal):
(JSC::tryCachePutBy):
(JSC::tryCacheInBy):
(JSC::tryCacheInstanceOf):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::setupGetByIdPrototypeCache):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot):
(JSC::JSGenericTypedArrayView<Adaptor>::put):
(JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty):
(JSC::JSGenericTypedArrayView<Adaptor>::deleteProperty):
* Source/JavaScriptCore/runtime/JSObjectInlines.h:
(JSC::JSObject::getNonIndexPropertySlot):
* Source/JavaScriptCore/runtime/PropertyName.h:
(JSC::isCanonicalNumericIndexString):
* Source/JavaScriptCore/runtime/StructureRareData.cpp:
(JSC::StructureRareData::cacheSpecialPropertySlow):

Canonical link: https://commits.webkit.org/254264@main
… not a number https://bugs.webkit.org/show_bug.cgi?id=259230 rdar://112292849

Reviewed by Alexey Shvayka.

This patch makes isCanonicalNumericIndexString early return for obvious non number cases
so that we avoid super costly number-to-string & string-to-number path.

* Source/JavaScriptCore/runtime/PropertyName.h:
(JSC::isCanonicalNumericIndexString):

Canonical link: https://commits.webkit.org/266080@main
…webkit.org/show_bug.cgi?id=259664 rdar://113162575

Reviewed by Mark Lam.

This makes less conservative on isCanonicalNumericIndexString. We only care "Infinity" and "NaN" cases here.

* JSTests/stress/typed-array-canonical.js: Added.
(shouldBe):
* Source/JavaScriptCore/runtime/PropertyName.h:
(JSC::isCanonicalNumericIndexString):

Canonical link: https://commits.webkit.org/266460@main
…ow_bug.cgi?id=263491

Reviewed by Darin Adler.

Add bounds check to StringView::operator[] and StringView::charactersAt() as a
hardening measure.

This patch was initialized a performance regression on Speedometer and Jetstream.
I used a profiler to find the call sites in hot code path and moved them away
from StringView::operator[].

As it stands, this patch is performance-neutral on Speedometer and Jetstream on
the various hardware models I A/B tested on.

* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::toDouble):
(JSC::jsToNumber):
* Source/JavaScriptCore/runtime/JSStringJoiner.cpp:
(JSC::appendStringToData):
(JSC::joinStrings):
(JSC::JSStringJoiner::joinSlow):
* Source/JavaScriptCore/runtime/PropertyName.h:
(JSC::fastIsCanonicalNumericIndexString):
(JSC::isCanonicalNumericIndexString):
* Source/WTF/wtf/text/StringImpl.h:
(WTF::StringImpl::span8 const):
(WTF::StringImpl::span16 const):
* Source/WTF/wtf/text/StringView.h:
(WTF::StringView::characterAt const):
(WTF::StringView::unsafeCharacterAt const):
(WTF::StringView::CodeUnits::Iterator::operator* const):
(WTF::findCommon):

Canonical link: https://commits.webkit.org/269630@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants