aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 9c33f542dc77..71a6efe5d8bd 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -232,13 +232,13 @@ static void flush_arg_page(struct linux_binprm *bprm, unsigned long pos,
232 232
233static int __bprm_mm_init(struct linux_binprm *bprm) 233static int __bprm_mm_init(struct linux_binprm *bprm)
234{ 234{
235 int err = -ENOMEM; 235 int err;
236 struct vm_area_struct *vma = NULL; 236 struct vm_area_struct *vma = NULL;
237 struct mm_struct *mm = bprm->mm; 237 struct mm_struct *mm = bprm->mm;
238 238
239 bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 239 bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
240 if (!vma) 240 if (!vma)
241 goto err; 241 return -ENOMEM;
242 242
243 down_write(&mm->mmap_sem); 243 down_write(&mm->mmap_sem);
244 vma->vm_mm = mm; 244 vma->vm_mm = mm;
@@ -251,28 +251,20 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
251 */ 251 */
252 vma->vm_end = STACK_TOP_MAX; 252 vma->vm_end = STACK_TOP_MAX;
253 vma->vm_start = vma->vm_end - PAGE_SIZE; 253 vma->vm_start = vma->vm_end - PAGE_SIZE;
254
255 vma->vm_flags = VM_STACK_FLAGS; 254 vma->vm_flags = VM_STACK_FLAGS;
256 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 255 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
257 err = insert_vm_struct(mm, vma); 256 err = insert_vm_struct(mm, vma);
258 if (err) { 257 if (err)
259 up_write(&mm->mmap_sem);
260 goto err; 258 goto err;
261 }
262 259
263 mm->stack_vm = mm->total_vm = 1; 260 mm->stack_vm = mm->total_vm = 1;
264 up_write(&mm->mmap_sem); 261 up_write(&mm->mmap_sem);
265
266 bprm->p = vma->vm_end - sizeof(void *); 262 bprm->p = vma->vm_end - sizeof(void *);
267
268 return 0; 263 return 0;
269
270err: 264err:
271 if (vma) { 265 up_write(&mm->mmap_sem);
272 bprm->vma = NULL; 266 bprm->vma = NULL;
273 kmem_cache_free(vm_area_cachep, vma); 267 kmem_cache_free(vm_area_cachep, vma);
274 }
275
276 return err; 268 return err;
277} 269}
278 270
@@ -1694,7 +1686,7 @@ int get_dumpable(struct mm_struct *mm)
1694 return (ret >= 2) ? 2 : ret; 1686 return (ret >= 2) ? 2 : ret;
1695} 1687}
1696 1688
1697int do_coredump(long signr, int exit_code, struct pt_regs * regs) 1689void do_coredump(long signr, int exit_code, struct pt_regs *regs)
1698{ 1690{
1699 struct core_state core_state; 1691 struct core_state core_state;
1700 char corename[CORENAME_MAX_SIZE + 1]; 1692 char corename[CORENAME_MAX_SIZE + 1];
@@ -1778,6 +1770,11 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1778 1770
1779 if (ispipe) { 1771 if (ispipe) {
1780 helper_argv = argv_split(GFP_KERNEL, corename+1, &helper_argc); 1772 helper_argv = argv_split(GFP_KERNEL, corename+1, &helper_argc);
1773 if (!helper_argv) {
1774 printk(KERN_WARNING "%s failed to allocate memory\n",
1775 __func__);
1776 goto fail_unlock;
1777 }
1781 /* Terminate the string before the first option */ 1778 /* Terminate the string before the first option */
1782 delimit = strchr(corename, ' '); 1779 delimit = strchr(corename, ' ');
1783 if (delimit) 1780 if (delimit)
@@ -1845,5 +1842,5 @@ fail_unlock:
1845 put_cred(cred); 1842 put_cred(cred);
1846 coredump_finish(mm); 1843 coredump_finish(mm);
1847fail: 1844fail:
1848 return retval; 1845 return;
1849} 1846}