Commit 7ec96efe authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

pie/vdso: convert (char *mem) to (uintptr_t mem)

Impact: drop additional casts all around. Cleanup.
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 3bf85ce9
...@@ -80,7 +80,6 @@ static inline bool is_vdso_mark(void *addr) ...@@ -80,7 +80,6 @@ static inline bool is_vdso_mark(void *addr)
} }
extern int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned long park_size); extern int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned long park_size);
extern int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t);
extern int vdso_proxify(char *who, struct vdso_symtable *sym_rt, extern int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
unsigned long vdso_rt_parked_at, size_t index, unsigned long vdso_rt_parked_at, size_t index,
VmaEntry *vmas, size_t nr_vmas); VmaEntry *vmas, size_t nr_vmas);
......
...@@ -88,6 +88,6 @@ static inline unsigned long vvar_vma_size(struct vdso_symtable *t) ...@@ -88,6 +88,6 @@ static inline unsigned long vvar_vma_size(struct vdso_symtable *t)
return t->vvar_end - t->vvar_start; return t->vvar_end - t->vvar_start;
} }
extern int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t); extern int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t);
#endif /* __CR_UTIL_VDSO_H__ */ #endif /* __CR_UTIL_VDSO_H__ */
...@@ -105,7 +105,8 @@ int vdso_proxify(char *who, struct vdso_symtable *sym_rt, ...@@ -105,7 +105,8 @@ int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
/* /*
* Find symbols in vDSO zone read from image. * Find symbols in vDSO zone read from image.
*/ */
if (vdso_fill_symtable((void *)vma_vdso->start, vma_entry_len(vma_vdso), &s)) if (vdso_fill_symtable((uintptr_t)vma_vdso->start,
vma_entry_len(vma_vdso), &s))
return -1; return -1;
/* /*
......
...@@ -523,7 +523,7 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args) ...@@ -523,7 +523,7 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
if (args->try_fill_symtable) { if (args->try_fill_symtable) {
struct vdso_symtable t; struct vdso_symtable t;
if (vdso_fill_symtable((void *)args->start, args->len, &t)) if (vdso_fill_symtable(args->start, args->len, &t))
args->is_vdso = false; args->is_vdso = false;
else else
args->is_vdso = true; args->is_vdso = true;
......
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
#define LOG_PREFIX "vdso: " #define LOG_PREFIX "vdso: "
/* Check if pointer is out-of-bound */ /* Check if pointer is out-of-bound */
static bool __ptr_oob(uintptr_t ptr, void *mem, size_t size) static bool __ptr_oob(uintptr_t ptr, uintptr_t start, size_t size)
{ {
uintptr_t start = (uintptr_t)mem;
uintptr_t end = start + size; uintptr_t end = start + size;
return ptr > end || ptr < start; return ptr > end || ptr < start;
...@@ -77,7 +76,7 @@ static int has_elf_identity(Ehdr_t *ehdr) ...@@ -77,7 +76,7 @@ static int has_elf_identity(Ehdr_t *ehdr)
return true; return true;
} }
int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t)
{ {
const char *vdso_symbols[VDSO_SYMBOL_MAX] = { const char *vdso_symbols[VDSO_SYMBOL_MAX] = {
ARCH_VDSO_SYMBOLS ARCH_VDSO_SYMBOLS
...@@ -113,7 +112,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) ...@@ -113,7 +112,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
/* /*
* We need PT_LOAD and PT_DYNAMIC here. Each once. * We need PT_LOAD and PT_DYNAMIC here. Each once.
*/ */
addr = (uintptr_t)mem + ehdr->e_phoff; addr = mem + ehdr->e_phoff;
for (i = 0; i < ehdr->e_phnum; i++, addr += sizeof(Phdr_t)) { for (i = 0; i < ehdr->e_phnum; i++, addr += sizeof(Phdr_t)) {
if (__ptr_oob(addr, mem, size)) if (__ptr_oob(addr, mem, size))
goto err_oob; goto err_oob;
...@@ -147,7 +146,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) ...@@ -147,7 +146,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
* Dynamic section tags should provide us the rest of information * Dynamic section tags should provide us the rest of information
* needed. Note that we're interested in a small set of tags. * needed. Note that we're interested in a small set of tags.
*/ */
addr = (uintptr_t)mem + dynamic->p_offset; addr = mem + dynamic->p_offset;
for (i = 0; i < dynamic->p_filesz / sizeof(*d); for (i = 0; i < dynamic->p_filesz / sizeof(*d);
i++, addr += sizeof(Dyn_t)) { i++, addr += sizeof(Dyn_t)) {
if (__ptr_oob(addr, mem, size)) if (__ptr_oob(addr, mem, size))
...@@ -179,12 +178,12 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) ...@@ -179,12 +178,12 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
return -EINVAL; return -EINVAL;
} }
addr = (uintptr_t)mem + dyn_strtab->d_un.d_val - load->p_vaddr; addr = mem + dyn_strtab->d_un.d_val - load->p_vaddr;
if (__ptr_oob(addr, mem, size)) if (__ptr_oob(addr, mem, size))
goto err_oob; goto err_oob;
dynsymbol_names = (void *)addr; dynsymbol_names = (void *)addr;
addr = (uintptr_t)mem + dyn_hash->d_un.d_ptr - load->p_vaddr; addr = mem + dyn_hash->d_un.d_ptr - load->p_vaddr;
if (__ptr_oob(addr, mem, size)) if (__ptr_oob(addr, mem, size))
goto err_oob; goto err_oob;
hash = (void *)addr; hash = (void *)addr;
...@@ -202,7 +201,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) ...@@ -202,7 +201,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
k = elf_hash((const unsigned char *)symbol); k = elf_hash((const unsigned char *)symbol);
for (j = bucket[k % nbucket]; j < nchain && chain[j] != STN_UNDEF; j = chain[j]) { for (j = bucket[k % nbucket]; j < nchain && chain[j] != STN_UNDEF; j = chain[j]) {
addr = (uintptr_t)mem + dyn_symtab->d_un.d_ptr - load->p_vaddr; addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
Sym_t *sym; Sym_t *sym;
char *name; char *name;
......
...@@ -257,7 +257,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -257,7 +257,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
s->vma_start = start; s->vma_start = start;
s->vma_end = end; s->vma_end = end;
ret = vdso_fill_symtable((void *)start, end - start, s); ret = vdso_fill_symtable(start, end - start, s);
if (ret) if (ret)
goto err; goto err;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment