Skip to content

vdso: move x86_64 stubs that outgrow their entry to the trampoline area - #361

Merged
congwang-mk merged 1 commit into
multikernel:mainfrom
saviourmk:vdso-x86-overflow
Nov 28, 2026
Merged

congwang-mk merged 1 commit into
multikernel:mainfrom
saviourmk:vdso-x86-overflow

Conversation

@saviourmk

Copy link
Copy Markdown
Contributor

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.

@congwang-mk
congwang-mk merged commit 83f66a2 into multikernel:main Nov 28, 2026
25 checks passed
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