Skip to content

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

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
merged 1 commit into from
May 26, 2022

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 26, 2022

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

@mikeash mikeash requested a review from DougGregor May 26, 2022 00:57
@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
@mikeash mikeash force-pushed the dont-trust-unmangled-names branch from 604eb05 to 8f072d1 Compare May 26, 2022 02:41
@mikeash
Copy link
Contributor Author

mikeash commented May 26, 2022

@swift-ci please test

@mikeash mikeash merged commit 0bf212a into swiftlang:main 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