summaryrefslogtreecommitdiffstats
path: root/fs/binfmt_elf.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-03-23 02:25:38 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-03-23 02:25:38 +0000
commit16b5d462f73eb29d1f67fa01cc1ea66afdc72569 (patch)
tree5407bd573f4840e473ea27cbe61e5c7a07131fcd /fs/binfmt_elf.c
parentce8a076e11e7e5ee36007f9a3eee5bb3744cb8f6 (diff)
Merge with Linux 2.3.99-pre2.
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r--fs/binfmt_elf.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 877d9e6d7..28f82594f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -40,7 +40,7 @@
#include <linux/elf.h>
static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs);
-static int load_elf_library(int fd);
+static int load_elf_library(struct file*);
extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);
extern void dump_thread(struct pt_regs *, struct user *);
@@ -503,16 +503,14 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
current->personality = PER_SVR4;
lock_kernel();
- interpreter_dentry = open_namei(elf_interpreter,
- 0, 0);
+ interpreter_dentry = open_namei(elf_interpreter);
unlock_kernel();
current->personality = old_pers;
} else
#endif
{
lock_kernel();
- interpreter_dentry = open_namei(elf_interpreter,
- 0, 0);
+ interpreter_dentry = open_namei(elf_interpreter);
unlock_kernel();
}
set_fs(old_fs);
@@ -797,9 +795,8 @@ out_free_ph:
/* This is really simpleminded and specialized - we are loading an
a.out library that is given an ELF header. */
-static int load_elf_library(int fd)
+static int load_elf_library(struct file *file)
{
- struct file * file;
struct dentry * dentry;
struct inode * inode;
struct elf_phdr *elf_phdata;
@@ -809,9 +806,6 @@ static int load_elf_library(int fd)
loff_t offset = 0;
error = -EACCES;
- file = fget(fd);
- if (!file || !file->f_op)
- goto out;
dentry = file->f_dentry;
inode = dentry->d_inode;
@@ -823,27 +817,27 @@ static int load_elf_library(int fd)
retval = file->f_op->read(file, (char *) &elf_ex, sizeof(elf_ex), &offset);
set_fs(USER_DS);
if (retval != sizeof(elf_ex))
- goto out_putf;
+ goto out;
if (memcmp(elf_ex.e_ident, ELFMAG, SELFMAG) != 0)
- goto out_putf;
+ goto out;
/* First of all, some simple consistency checks */
if (elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 ||
!elf_check_arch(elf_ex.e_machine) ||
(!inode->i_fop || !inode->i_fop->mmap))
- goto out_putf;
+ goto out;
/* Now read in all of the header information */
j = sizeof(struct elf_phdr) * elf_ex.e_phnum;
if (j > ELF_EXEC_PAGESIZE)
- goto out_putf;
+ goto out;
error = -ENOMEM;
elf_phdata = (struct elf_phdr *) kmalloc(j, GFP_KERNEL);
if (!elf_phdata)
- goto out_putf;
+ goto out;
/* N.B. check for error return?? */
retval = read_exec(dentry, elf_ex.e_phoff, (char *) elf_phdata,
@@ -858,6 +852,7 @@ static int load_elf_library(int fd)
while (elf_phdata->p_type != PT_LOAD) elf_phdata++;
/* Now use mmap to map the library into memory. */
+ down(&current->mm->mmap_sem);
error = do_mmap(file,
ELF_PAGESTART(elf_phdata->p_vaddr),
(elf_phdata->p_filesz +
@@ -866,6 +861,7 @@ static int load_elf_library(int fd)
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
(elf_phdata->p_offset -
ELF_PAGEOFFSET(elf_phdata->p_vaddr)));
+ up(&current->mm->mmap_sem);
if (error != ELF_PAGESTART(elf_phdata->p_vaddr))
goto out_free_ph;
@@ -883,8 +879,6 @@ static int load_elf_library(int fd)
out_free_ph:
kfree(elf_phdata);
-out_putf:
- fput(file);
out:
return error;
}