[CRIU] [PATCH 2/2] vdso: Proxify vDSO code on restore

Cyrill Gorcunov gorcunov at openvz.org
Thu Apr 18 02:16:00 EDT 2013


When tasks are restored in a kernel which version differ from the one
they were being dumped on, the vDSO content may has been changed thus
any call to vDSO service routine will lead to SIGBUS in a better case
or in wrong results without notice in a worst one.

So to work this situation out we need a that named vDSO proxy, where
any call to original vDSO service routine shall be redirected to
a valid runtime 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 memory the kernel provides us and remember
    its structure and functions addresses once restore started.
 2) When all VMAs the task has are read we append a new one with
    size of run-time vDSO.
 3) Fill new vDSO VMA with data from the run time vDSO
 4) Patch old vDSO entry points to redirect calls to new vDSO entries.

There are paths for improvements

 - lookup for appropriate hole between VMAs from image and map
   a new vDSO here, because there might be no place for a new VMA
   after all read from image
 - don't copy run time vDSO contents but rather re-map runtime
   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>
---
 cr-restore.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 94 insertions(+), 2 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-vdso-Proxify-vDSO-code-on-restore.patch
Type: text/x-patch
Size: 4425 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20130418/5312f8ec/attachment-0001.bin>


More information about the CRIU mailing list