[CRIU] [PATCH 07/13] vdso: Initialize vdso data on startup

Pavel Emelyanov xemul at parallels.com
Thu May 23 07:04:54 EDT 2013


On 05/22/2013 11:09 PM, Cyrill Gorcunov wrote:
> 
> 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 at openvz.org>
> ---
>  Makefile         |  2 +-
>  Makefile.crtools |  1 +
>  cr-dump.c        |  4 +++
>  cr-restore.c     |  4 +++
>  include/vdso.h   |  1 +
>  vdso.c           | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 86 insertions(+), 1 deletion(-)
>  create mode 100644 vdso.c
> 
> --- /dev/null
> +++ b/vdso.c
> @@ -0,0 +1,75 @@
> +#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: "
> +
> +static symtable_t sym_rt = SYMTABLE_INIT;
> +
> +#if defined(CONFIG_X86_64)

Same here. arch/x86/vdso.c please.

> +static int vdso_fill_self_symtable(symtable_t *s)
> +{
> +	char buf[512];
> +	int ret = -1;
> +	FILE *maps;
> +
> +	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;
> +}
> +#endif /* CONFIG_X86_64 */
> +
> +int vdso_init(void)
> +{
> +#if defined(CONFIG_X86_64)
> +	if (vdso_fill_self_symtable(&sym_rt))
> +		return -1;
> +#endif
> +	return 0;
> +}




More information about the CRIU mailing list