-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reexec with /proc/self/exe
on Linux
#11283
Conversation
5b6cc3c
to
623b20e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't affect graceful restart, right? Since that is often used for upgrades and we'd want to load the new binary
Yes, |
ff6daf7
to
51a3765
Compare
51a3765
to
b02107d
Compare
8b7f9a4
to
bf35c15
Compare
bf35c15
to
d68ff0b
Compare
@nklaassen @lxea PTAL, this should be the final version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the in-depth explanations also!
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
* Reexec with `/proc/self/exe` on Linux * Add a check for qemu-user * Add comment
Right now we're using the output of
os.Executable
to decide which binary to launch for our internalteleport exec
/teleport forward
/teleport checkhomedir
reexecs. If the binary is replaced, for instance during an upgrade, we end up calling the new binary rather than the old one - which works fine but relies on the new version working correctly and having the exact semantics. If the binary is deleted (by accident, for instance) thetsh ssh
functionality breaks, which could be problematic if Teleport is the only way to remote into a system.We don't have a better way on Darwin, but on Linux (starting from Linux 2.2) running
execve
directly on/proc/self/exe
will execute the currently running binary no matter what happened to any paths referring to it. To compensate for a qemu-user bug (see https://gitlab.com/qemu-project/qemu/-/issues/927) and general qemu-user weirdness, we do a runtime check at init time to try to detect if we're in a qemu-user that is misbehaving, and if not, we end up opening our binary and then reexecuting it via/proc/self/fd/N
.Closes #11052.