mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
vdso: Initialize vdso data on startup
During criu startup we need to fill symbol table of own run-time vdso provided by the kernel. We will need this data for vdso proxy. Because this functions are not used in restorer code, we move them out of PIE (since PIE code must remain as small as possible). Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
61cc86ddd2
commit
e44b3dbe84
@@ -47,6 +47,7 @@ obj-y += page-xfer.o
|
||||
obj-y += page-read.o
|
||||
obj-y += kerndat.o
|
||||
obj-y += stats.o
|
||||
obj-y += arch/$(ARCH)/vdso.o
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
incdeps := y
|
||||
|
@@ -1,19 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "asm/string.h"
|
||||
#include "asm/types.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "crtools.h"
|
||||
#include "vdso.h"
|
||||
#include "log.h"
|
||||
|
||||
|
16
arch/arm/vdso.c
Normal file
16
arch/arm/vdso.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "vdso.h"
|
||||
#include "log.h"
|
||||
|
||||
#ifdef LOG_PREFIX
|
||||
# undef LOG_PREFIX
|
||||
#endif
|
||||
#define LOG_PREFIX "vdso: "
|
||||
|
||||
struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT;
|
||||
|
||||
int vdso_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
71
arch/x86/vdso.c
Normal file
71
arch/x86/vdso.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "crtools.h"
|
||||
#include "kerndat.h"
|
||||
#include "vdso.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef LOG_PREFIX
|
||||
# undef LOG_PREFIX
|
||||
#endif
|
||||
#define LOG_PREFIX "vdso: "
|
||||
|
||||
struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT;
|
||||
|
||||
static int vdso_fill_self_symtable(struct vdso_symtable *s)
|
||||
{
|
||||
char buf[512];
|
||||
int ret = -1;
|
||||
FILE *maps;
|
||||
|
||||
VDSO_INIT_SYMTABLE(s);
|
||||
|
||||
maps = fopen("/proc/self/maps", "r");
|
||||
if (!maps) {
|
||||
pr_perror("Can't open self-vma");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), maps)) {
|
||||
unsigned long start, end;
|
||||
|
||||
if (strstr(buf, "[vdso]") == NULL)
|
||||
continue;
|
||||
|
||||
ret = sscanf(buf, "%lx-%lx", &start, &end);
|
||||
if (ret != 2) {
|
||||
ret = -1;
|
||||
pr_err("Can't find vDSO bounds\n");
|
||||
break;
|
||||
}
|
||||
|
||||
s->vma_start = start;
|
||||
s->vma_end = end;
|
||||
|
||||
ret = vdso_fill_symtable((void *)start, end - start, s);
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(maps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vdso_init(void)
|
||||
{
|
||||
if (vdso_fill_self_symtable(&vdso_sym_rt))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
@@ -62,6 +62,7 @@
|
||||
#include "stats.h"
|
||||
#include "mem.h"
|
||||
#include "page-pipe.h"
|
||||
#include "vdso.h"
|
||||
|
||||
#include "asm/dump.h"
|
||||
|
||||
@@ -1683,6 +1684,9 @@ int cr_dump_tasks(pid_t pid)
|
||||
if (cpu_init())
|
||||
goto err;
|
||||
|
||||
if (vdso_init())
|
||||
goto err;
|
||||
|
||||
if (write_img_inventory())
|
||||
goto err;
|
||||
|
||||
|
@@ -57,6 +57,7 @@
|
||||
#include "file-lock.h"
|
||||
#include "page-read.h"
|
||||
#include "sysctl.h"
|
||||
#include "vdso.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
#include "protobuf/sa.pb-c.h"
|
||||
@@ -1315,6 +1316,9 @@ int cr_restore_tasks(struct cr_options *opts)
|
||||
if (cpu_init() < 0)
|
||||
return -1;
|
||||
|
||||
if (vdso_init())
|
||||
return -1;
|
||||
|
||||
if (prepare_task_entries() < 0)
|
||||
return -1;
|
||||
|
||||
|
@@ -66,4 +66,7 @@ static inline unsigned long vdso_vma_size(struct vdso_symtable *t)
|
||||
return t->vma_end - t->vma_start;
|
||||
}
|
||||
|
||||
extern struct vdso_symtable vdso_sym_rt;
|
||||
extern int vdso_init(void);
|
||||
|
||||
#endif /* __CR_VDSO_H__ */
|
||||
|
Reference in New Issue
Block a user