Skip to content

[5.7][Runtime] Don't try to demangle unprefixed untrusted names. Remove operator new/delete hackery. #59096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 26, 2022

Cherry-pick #59095 to release/5.7.

The operator new/delete overrides aren't working out due to inconsistent inlining of std::string creation/deletion. We can end up creating one with the global new but destroying it with our local delete. If they aren't compatible, this crashes.

Instead, avoid problematic new/delete activity coming from lookup of ObjC class names. Names passed to getObjCClassByMangledName/swift_stdlib_getTypeByMangledNameUntrusted must either have a standard mangled name prefix, start with a digit (for unprefixed mangled names) or use the convenience dot syntax. Check for those up front and immediately reject anything else. This has the added bonus of failing more quickly for non-Swift names.

rdar://93863030

@mikeash mikeash requested a review from a team as a code owner May 26, 2022 01:00
@mikeash
Copy link
Contributor Author

mikeash commented May 26, 2022

@swift-ci please test

…erator new/delete hackery.

The operator new/delete overrides aren't working out due to inconsistent inlining of std::string creation/deletion. We can end up creating one with the global new but destroying it with our local delete. If they aren't compatible, this crashes.

Instead, avoid problematic new/delete activity coming from lookup of ObjC class names. Names passed to getObjCClassByMangledName must either have a standard mangled name prefix, start with a digit (for unprefixed mangled names) or use the convenience dot syntax. Check for those up front and immediately reject anything else. This has the added bonus of failing more quickly for non-Swift names.

rdar://93863030
(cherry picked from commit 8f072d1)
@mikeash mikeash force-pushed the dont-trust-unmangled-names-5.7 branch from c730626 to c5fc40e Compare May 26, 2022 02:43
@mikeash
Copy link
Contributor Author

mikeash commented May 26, 2022

@swift-ci please test

@mikeash mikeash merged commit 77783a4 into swiftlang:release/5.7 May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants