Repository navigation
vdso: move x86_64 stubs that outgrow their entry to the trampoline area - #361
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On x86_64 patch() wrote every stub straight over the function entry, on the assumption that the vDSO functions are long. On the 7.0.0-44-generic Ubuntu kernel I'm running, __vdso_gettimeofday and __vdso_clock_gettime are each a single 5-byte jmp into shared code, 16 bytes in front of __vdso_time and __vdso_clock_getres. The 30 and 35 byte time_start stubs ran into those neighbours. gettimeofday then fell into the time stub written after it and returned the raw seconds with an unshifted tv_sec, and clock_getres returned garbage without filling in the resolution.
A stub is still written in place when it fits inside the symbol's st_size (or when the symbol has no size recorded), so kernels with long vDSO functions behave exactly as before. When it doesn't fit, it goes to the trampoline area past the end of the image that arm64 and riscv64 already use, and the entry gets a 5-byte jmp to it. parse_vdso_symbols now returns each symbol's size along with its offset.
I added an integration test under time_start that checks gettimeofday returns 0 with a shifted tv_sec, clock_getres returns 0 with a sane resolution, and clock_gettime is still shifted. On this kernel it fails on main (gettimeofday returns 1795752658 with year 2026, clock_getres returns 426861184) and passes with the change. On kernels with long vDSO functions it passes either way. There is also a unit test for the jmp encoding, and I ran the vdso unit tests and the test_determinism and test_checkpoint integration tests.