]> xenbits.xensource.com Git - unikraft/unikraft.git/commit
lib/syscall_shim/arch/x86_64: Restore `RIP` from the auxiliary stack
authorSergiu Moga <sergiu@unikraft.io>
Mon, 24 Mar 2025 16:46:16 +0000 (18:46 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Thu, 17 Apr 2025 12:33:46 +0000 (12:33 +0000)
commit06f9907e2d8597665167f016d27b6015e7dc53e2
treeb229b1388912f70dbfa52e78e367774ad37b7631
parent87fa095ae8bfffa4bd9b621fa9915451db8a31e5
lib/syscall_shim/arch/x86_64: Restore `RIP` from the auxiliary stack

Before this patch, we would simply rely on the original pushed RIP
following the call instruction that got to our assembly wrapper.
However this may not be the same in cases such as those of the clone
or vfork system calls if the child were to reuse the stack: the child
could pop the return address before the parent gets the chance to do it
and even call some other functions (like execve), overwriting whatever
previously was at the bottom of the stack that the parent had prior
to invoking the system call.

To solve this, simply use the RIP pushed at the beginning of the wrapper
instead of assuming the bottom of the stack is untouched.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1618
lib/syscall_shim/arch/x86_64/include/arch/syscall_prologue.h