mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
VM: add "vm_mmap()" helper function
This continues the theme started with vm_brk() and vm_munmap(): vm_mmap() does the same thing as do_mmap(), but additionally does the required VM locking. This uninlines (and rewrites it to be clearer) do_mmap(), which sadly duplicates it in mm/mmap.c and mm/nommu.c. But that way we don't have to export our internal do_mmap_pgoff() function. Some day we hopefully don't have to export do_mmap() either, if all modular users can become the simpler vm_mmap() instead. We're actually very close to that already, with the notable exception of the (broken) use in i810, and a couple of stragglers in binfmt_elf. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
a46ef99d80
commit
6be5ceb02e
15 changed files with 87 additions and 97 deletions
|
@ -319,24 +319,20 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||
goto beyond_if;
|
||||
}
|
||||
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
error = do_mmap(bprm->file, N_TXTADDR(ex), ex.a_text,
|
||||
error = vm_mmap(bprm->file, N_TXTADDR(ex), ex.a_text,
|
||||
PROT_READ | PROT_EXEC,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
|
||||
fd_offset);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
|
||||
if (error != N_TXTADDR(ex)) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
|
||||
error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
|
||||
fd_offset + ex.a_text);
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
if (error != N_DATADDR(ex)) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
return error;
|
||||
|
@ -417,12 +413,10 @@ static int load_aout_library(struct file *file)
|
|||
goto out;
|
||||
}
|
||||
/* Now use mmap to map the library into memory. */
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
|
||||
error = vm_mmap(file, start_addr, ex.a_text + ex.a_data,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
|
||||
N_TXTOFF(ex));
|
||||
up_write(¤t->mm->mmap_sem);
|
||||
retval = error;
|
||||
if (error != start_addr)
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue