aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/fs/exec.c b/fs/exec.c
index d68c378a3137..ba99e1abb1aa 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -115,13 +115,16 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
115 struct file *file; 115 struct file *file;
116 char *tmp = getname(library); 116 char *tmp = getname(library);
117 int error = PTR_ERR(tmp); 117 int error = PTR_ERR(tmp);
118 static const struct open_flags uselib_flags = {
119 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
120 .acc_mode = MAY_READ | MAY_EXEC | MAY_OPEN,
121 .intent = LOOKUP_OPEN
122 };
118 123
119 if (IS_ERR(tmp)) 124 if (IS_ERR(tmp))
120 goto out; 125 goto out;
121 126
122 file = do_filp_open(AT_FDCWD, tmp, 127 file = do_filp_open(AT_FDCWD, tmp, &uselib_flags, LOOKUP_FOLLOW);
123 O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
124 MAY_READ | MAY_EXEC | MAY_OPEN);
125 putname(tmp); 128 putname(tmp);
126 error = PTR_ERR(file); 129 error = PTR_ERR(file);
127 if (IS_ERR(file)) 130 if (IS_ERR(file))
@@ -275,6 +278,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
275 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP; 278 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
276 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 279 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
277 INIT_LIST_HEAD(&vma->anon_vma_chain); 280 INIT_LIST_HEAD(&vma->anon_vma_chain);
281
282 err = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1);
283 if (err)
284 goto err;
285
278 err = insert_vm_struct(mm, vma); 286 err = insert_vm_struct(mm, vma);
279 if (err) 287 if (err)
280 goto err; 288 goto err;
@@ -716,10 +724,13 @@ struct file *open_exec(const char *name)
716{ 724{
717 struct file *file; 725 struct file *file;
718 int err; 726 int err;
727 static const struct open_flags open_exec_flags = {
728 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
729 .acc_mode = MAY_EXEC | MAY_OPEN,
730 .intent = LOOKUP_OPEN
731 };
719 732
720 file = do_filp_open(AT_FDCWD, name, 733 file = do_filp_open(AT_FDCWD, name, &open_exec_flags, LOOKUP_FOLLOW);
721 O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
722 MAY_EXEC | MAY_OPEN);
723 if (IS_ERR(file)) 734 if (IS_ERR(file))
724 goto out; 735 goto out;
725 736