2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

vdso: fix segmentation fault caused by char pointer array

When I compile criu with "make DEBUG=1" and run it to restore my
program, it produces a segmentation fault.

In aarch64, with compile flag "-O0", when criu executes the code in pie,
it is unable to visit the content of ARCH_VDSO_SYMBOLS. So I put these
variables into the stack.

Signed-off-by: anatasluo <luolongjuna@gmail.com>
This commit is contained in:
anatasluo
2021-01-29 13:48:57 +00:00
committed by Andrei Vagin
parent 909ce55d8c
commit f983a55e68
7 changed files with 75 additions and 39 deletions

View File

@@ -16,15 +16,16 @@
* Workaround for VDSO array symbol table's relocation.
* XXX: remove when compel/piegen will support aarch64.
*/
static const char* __maybe_unused aarch_vdso_symbol1 = "__kernel_clock_getres";
static const char* __maybe_unused aarch_vdso_symbol2 = "__kernel_clock_gettime";
static const char* __maybe_unused aarch_vdso_symbol3 = "__kernel_gettimeofday";
static const char* __maybe_unused aarch_vdso_symbol4 = "__kernel_rt_sigreturn";
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \
const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
const char* aarch_vdso_symbol3 = "__kernel_gettimeofday"; \
const char* aarch_vdso_symbol4 = "__kernel_rt_sigreturn";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3, \
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3, \
aarch_vdso_symbol4
extern void write_intraprocedure_branch(unsigned long to, unsigned long from);

View File

@@ -11,8 +11,11 @@
*/
#define VDSO_SYMBOL_MAX 2
#define VDSO_SYMBOL_GTOD 1
#define ARCH_VDSO_SYMBOLS \
"__vdso_clock_gettime", \
"__vdso_gettimeofday"
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \
const char* aarch_vdso_symbol2 = "__vdso_gettimeofday";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2,
#endif /* __CR_ASM_VDSO_H__ */

View File

@@ -14,10 +14,14 @@
*/
#define VDSO_SYMBOL_MAX 3
#define VDSO_SYMBOL_GTOD 0
#define ARCH_VDSO_SYMBOLS \
"__vdso_clock_gettime", \
"__vdso_gettimeofday", \
"__vdso_clock_getres"
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \
const char* aarch_vdso_symbol2 = "__vdso_gettimeofday"; \
const char* aarch_vdso_symbol3 = "__vdso_clock_getres";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3,
#endif /* __CR_ASM_VDSO_H__ */

View File

@@ -14,16 +14,28 @@
*/
#define VDSO_SYMBOL_MAX 10
#define VDSO_SYMBOL_GTOD 5
#define ARCH_VDSO_SYMBOLS \
"__kernel_clock_getres", \
"__kernel_clock_gettime", \
"__kernel_get_syscall_map", \
"__kernel_get_tbfreq", \
"__kernel_getcpu", \
"__kernel_gettimeofday", \
"__kernel_sigtramp_rt64", \
"__kernel_sync_dicache", \
"__kernel_sync_dicache_p5", \
"__kernel_time"
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \
const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
const char* aarch_vdso_symbol3 = "__kernel_get_syscall_map"; \
const char* aarch_vdso_symbol4 = "__kernel_get_tbfreq"; \
const char* aarch_vdso_symbol5 = "__kernel_getcpu"; \
const char* aarch_vdso_symbol6 = "__kernel_gettimeofday"; \
const char* aarch_vdso_symbol7 = "__kernel_sigtramp_rt64"; \
const char* aarch_vdso_symbol8 = "__kernel_sync_dicache"; \
const char* aarch_vdso_symbol9 = "__kernel_sync_dicache_p5"; \
const char* aarch_vdso_symbol10 = "__kernel_time";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3, \
aarch_vdso_symbol4, \
aarch_vdso_symbol5, \
aarch_vdso_symbol6, \
aarch_vdso_symbol7, \
aarch_vdso_symbol8, \
aarch_vdso_symbol9, \
aarch_vdso_symbol10
#endif /* __CR_ASM_VDSO_H__ */

View File

@@ -12,13 +12,18 @@
#define VDSO_SYMBOL_GTOD 0
/*
* This definition is used in pie/util-vdso.c to initialize the vdso symbol
* These definitions are used in pie/util-vdso.c to initialize the vdso symbol
* name string table 'vdso_symbols'
*/
#define ARCH_VDSO_SYMBOLS \
"__kernel_gettimeofday", \
"__kernel_clock_gettime", \
"__kernel_clock_getres", \
"__kernel_getcpu"
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__kernel_gettimeofday"; \
const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
const char* aarch_vdso_symbol3 = "__kernel_clock_getres"; \
const char* aarch_vdso_symbol4 = "__kernel_getcpu";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3, \
aarch_vdso_symbol4
#endif /* __CR_ASM_VDSO_H__ */

View File

@@ -35,13 +35,22 @@
* vsyscall will be patched again when addressing:
* https://github.com/checkpoint-restore/criu/issues/512
*/
#define ARCH_VDSO_SYMBOLS \
"__vdso_clock_gettime", \
"__vdso_getcpu", \
"__vdso_gettimeofday", \
"__vdso_time", \
"__kernel_sigreturn", \
"__kernel_rt_sigreturn"
#define ARCH_VDSO_SYMBOLS_LIST \
const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \
const char* aarch_vdso_symbol2 = "__vdso_getcpu"; \
const char* aarch_vdso_symbol3 = "__vdso_gettimeofday"; \
const char* aarch_vdso_symbol4 = "__vdso_time"; \
const char* aarch_vdso_symbol5 = "__kernel_sigreturn"; \
const char* aarch_vdso_symbol6 = "__kernel_rt_sigreturn";
#define ARCH_VDSO_SYMBOLS \
aarch_vdso_symbol1, \
aarch_vdso_symbol2, \
aarch_vdso_symbol3, \
aarch_vdso_symbol4, \
aarch_vdso_symbol5, \
aarch_vdso_symbol6
/* "__kernel_vsyscall", */

View File

@@ -219,6 +219,8 @@ static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
struct vdso_symtable *t, uintptr_t dynsymbol_names,
Hash_t *hash, Dyn_t *dyn_symtab)
{
ARCH_VDSO_SYMBOLS_LIST
const char *vdso_symbols[VDSO_SYMBOL_MAX] = {
ARCH_VDSO_SYMBOLS
};