Skip to content
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

Check if TLS segments are padded at runtime #404

Open
ayrtonm opened this issue Oct 2, 2024 · 2 comments
Open

Check if TLS segments are padded at runtime #404

ayrtonm opened this issue Oct 2, 2024 · 2 comments
Labels
threads tooling Tools for debugging compartmentalized programs.

Comments

@ayrtonm
Copy link
Contributor

ayrtonm commented Oct 2, 2024

I think we already do some page-alignment checks, but it'd be nice to check that TLS segment sizes are a multiple of the page size. This would avoid the issue @randomPoison hit with zlib.

@fw-immunant
Copy link
Contributor

fw-immunant commented Oct 3, 2024

One problem here is that we don't actually raise the size of the TLS segment size to a multiple of 4096, but add 4096 to the size to ensure that the last page of the TLS region is not shared with the TLS region of the next shared object. Padding to a multiple of 4096 does not ensure this because we don't know the alignment at which the TLS region will start based on other shared objects that have already been laid out. Even if we did align to 4096, we could get false positives with such a check as the unpadded library's TLS segment could happen to be a multiple of 4096 bytes. But we could pad to the second next multiple of 4096 which would allow us to do this kind of (best-effort) check.

It might be easier to add some other, less confounded, signature with the pad-tls tool.

@fw-immunant fw-immunant added threads tooling Tools for debugging compartmentalized programs. labels Oct 3, 2024
@ayrtonm
Copy link
Contributor Author

ayrtonm commented Oct 3, 2024

we could get false positives

ok I guess if a binary that wouldn't be pkey_mprotected correctly can still have TLS segments with sizes that are multiples of a page then we should just add a signature like you're suggesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
threads tooling Tools for debugging compartmentalized programs.
Projects
None yet
Development

No branches or pull requests

2 participants