[CRIU] [PATCH 4/4] arch: x86 -- Add proxification of vDSO calls
Cyrill Gorcunov
gorcunov at openvz.org
Tue Apr 16 14:28:02 EDT 2013
When tasks are restored in a kernel which version differ from the
one they were being dumped on, the vDSO content may have been changed
thus any call to vDSO service routine will lead to SIGBUS in better case
or in wrong results without notice in worst one.
So to work this situatio out we need a that named vDSO proxy, thus any
call to original vDSO service routine shall be redirected to valid run
time vDSO supplied by the kernel we're restoring on.
In terms of ugly ascii gprahics it might be represented as following.
Original vDSO in image
======================
+---------------------------+
| __vdso_getcpu |
| ... |
| function body here |
+---------------------------+
| __vdso_time |
| ... |
| function body here |
+---------------------------+
...
Run-time proxified calls
========================
Mapped from image and then patched
+---------------------------+
| __vdso_getcpu |
| redirect +----+
| int3 | |
+---------------------------+ |
| __vdso_time | |
| redirect +-+ |
| int3 | | |
+---------------------------+ | |
... | |
| | New memory area with valid vDSO content
| | +---------------------------+
| | | __vdso_getcpu |
| +->| ... |
| | function body here |
| +---------------------------+
| | __vdso_time |
+---->| ... |
| function body here |
+---------------------------+
...
To achieve this we
1) Read vDSO from the image. If there is no image -- we do nothing.
2) Read vDSO from memory the kernel provides us and remember its structure
and functions addresses.
3) When all VMAs the task has are read we append new one with size of run-time
vDSO.
4) Fill new vDSO VMA with data from the run time vDSO
5) Patch old vDSO entry points to redirect calls to new vDSO entries.
This is far from being optimal, and better do
- lookup for appropriate hole between VMAs from image and map new vDSO here,
because there might be no place for new VMA after all read from image
- don't copy run time vDSO contents but rather re-map run-time vDSO to the
address needed at very late stage of restore
Even though, this patch provides a ground for future development and
known to work.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
arch/x86/crtools.c | 55 +++++++++++++++++++++++++++
arch/x86/vdso.c | 37 ++++++++++++++++++
cr-restore.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
include/vdso.h | 4 ++
4 files changed, 201 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-arch-x86-Add-proxification-of-vDSO-calls.patch
Type: text/x-patch
Size: 8600 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20130416/65e4a57f/attachment-0001.bin>
More information about the CRIU
mailing list