提交 a2357223 编写于 作者: C Christoph Hellwig 提交者: Greg Ungerer

binfmt_flat: don't offset the data start

Ever since the initial commit of the binfmt_flat shared library
support back in the bitkeeper days we've offset the actual in-memory
.data start by one field per possible shared library, or 1 in case
shared library support isn't enabled.  I can't find anything in the
loader that actually makes use of it, nor was it present before
shared library support it.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NGreg Ungerer <gerg@linux-m68k.org>
上级 a445d988
...@@ -573,7 +573,7 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -573,7 +573,7 @@ static int load_flat_file(struct linux_binprm *bprm,
goto err; goto err;
} }
len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long); len = data_len + extra;
len = PAGE_ALIGN(len); len = PAGE_ALIGN(len);
realdatastart = vm_mmap(NULL, 0, len, realdatastart = vm_mmap(NULL, 0, len,
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
...@@ -587,9 +587,7 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -587,9 +587,7 @@ static int load_flat_file(struct linux_binprm *bprm,
vm_munmap(textpos, text_len); vm_munmap(textpos, text_len);
goto err; goto err;
} }
datapos = ALIGN(realdatastart + datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN);
MAX_SHARED_LIBS * sizeof(unsigned long),
FLAT_DATA_ALIGN);
pr_debug("Allocated data+bss+stack (%u bytes): %lx\n", pr_debug("Allocated data+bss+stack (%u bytes): %lx\n",
data_len + bss_len + stack_len, datapos); data_len + bss_len + stack_len, datapos);
...@@ -619,7 +617,7 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -619,7 +617,7 @@ static int load_flat_file(struct linux_binprm *bprm,
memp_size = len; memp_size = len;
} else { } else {
len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(u32); len = text_len + data_len + extra;
len = PAGE_ALIGN(len); len = PAGE_ALIGN(len);
textpos = vm_mmap(NULL, 0, len, textpos = vm_mmap(NULL, 0, len,
PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
...@@ -634,9 +632,7 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -634,9 +632,7 @@ static int load_flat_file(struct linux_binprm *bprm,
} }
realdatastart = textpos + ntohl(hdr->data_start); realdatastart = textpos + ntohl(hdr->data_start);
datapos = ALIGN(realdatastart + datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN);
MAX_SHARED_LIBS * sizeof(u32),
FLAT_DATA_ALIGN);
reloc = (__be32 __user *) reloc = (__be32 __user *)
(datapos + (ntohl(hdr->reloc_start) - text_len)); (datapos + (ntohl(hdr->reloc_start) - text_len));
...@@ -653,8 +649,9 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -653,8 +649,9 @@ static int load_flat_file(struct linux_binprm *bprm,
(text_len + full_data (text_len + full_data
- sizeof(struct flat_hdr)), - sizeof(struct flat_hdr)),
0); 0);
memmove((void *) datapos, (void *) realdatastart, if (datapos != realdatastart)
full_data); memmove((void *)datapos, (void *)realdatastart,
full_data);
#else #else
/* /*
* This is used on MMU systems mainly for testing. * This is used on MMU systems mainly for testing.
...@@ -710,8 +707,7 @@ static int load_flat_file(struct linux_binprm *bprm, ...@@ -710,8 +707,7 @@ static int load_flat_file(struct linux_binprm *bprm,
if (IS_ERR_VALUE(result)) { if (IS_ERR_VALUE(result)) {
ret = result; ret = result;
pr_err("Unable to read code+data+bss, errno %d\n", ret); pr_err("Unable to read code+data+bss, errno %d\n", ret);
vm_munmap(textpos, text_len + data_len + extra + vm_munmap(textpos, text_len + data_len + extra);
MAX_SHARED_LIBS * sizeof(u32));
goto err; goto err;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册