Skip to content

Runtime: Only demangle symbolic references in constant memory. #17405

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
Jun 25, 2018

Conversation

jckarter
Copy link
Contributor

This provides a slight amount of defense against attackers constructing mangled names with offsets crafted to JOP the runtime into attacker-controlled code. (Someone could still find some random code or constant data artifact in a binary that looks like a mangled string with symbolic references and theoretically attack that way, but they at least wouldn't be able to construct their own string entirely.)

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@swift-ci Please benchmark

@jckarter jckarter requested a review from DougGregor June 21, 2018 22:36
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 493ac30db3ae8e045083d5fd18a016790cf3c1e9

@swift-ci
Copy link
Contributor

Build comment file:

Build failed before running benchmark.


Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! LGTM

@jckarter jckarter force-pushed the protect-symbolic-references branch from 493ac30 to 515b065 Compare June 25, 2018 16:46
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter jckarter force-pushed the protect-symbolic-references branch from 515b065 to fd3e209 Compare June 25, 2018 16:48
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 515b065b68465d16ceb1cebdcc6161ecefc14894

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 515b065b68465d16ceb1cebdcc6161ecefc14894

This provides a slight amount of defense against attackers constructing mangled names with offsets crafted to JOP the runtime into attacker-controlled code. (Someone could still find some random code or constant data artifact in a binary that *looks* like a mangled string with symbolic references and theoretically attack that way, but they at least wouldn't be able to construct their own string entirely.)
@jckarter jckarter force-pushed the protect-symbolic-references branch from fd3e209 to 99842f9 Compare June 25, 2018 17:22
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fd3e209d85a7a3ba71435bb2038c88491c0c8e2f

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fd3e209d85a7a3ba71435bb2038c88491c0c8e2f

@jckarter jckarter merged commit 77ed0e1 into swiftlang:master Jun 25, 2018
@gparker42
Copy link
Contributor

Why is this using an availability check instead of a weak import check? Did you verify that the symbol reference to _dyld_is_memory_immutable is a weak import in the built image? (If it is not then this will crash at launch when running on old OS versions.)

@jckarter
Copy link
Contributor Author

Ah, I see it's not declared with availability attributes in the dyld headers. I'll fix that.

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.

4 participants