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, 12 insertions, 17 deletions
diff --git a/fs/exec.c b/fs/exec.c
index a04a575ad433..ba73797eb4cb 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -126,8 +126,7 @@ asmlinkage long sys_uselib(const char __user * library)
126 struct nameidata nd; 126 struct nameidata nd;
127 int error; 127 int error;
128 128
129 nd.intent.open.flags = FMODE_READ; 129 error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);
130 error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
131 if (error) 130 if (error)
132 goto out; 131 goto out;
133 132
@@ -139,7 +138,7 @@ asmlinkage long sys_uselib(const char __user * library)
139 if (error) 138 if (error)
140 goto exit; 139 goto exit;
141 140
142 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); 141 file = nameidata_to_filp(&nd, O_RDONLY);
143 error = PTR_ERR(file); 142 error = PTR_ERR(file);
144 if (IS_ERR(file)) 143 if (IS_ERR(file))
145 goto out; 144 goto out;
@@ -167,6 +166,7 @@ asmlinkage long sys_uselib(const char __user * library)
167out: 166out:
168 return error; 167 return error;
169exit: 168exit:
169 release_open_intent(&nd);
170 path_release(&nd); 170 path_release(&nd);
171 goto out; 171 goto out;
172} 172}
@@ -309,40 +309,36 @@ void install_arg_page(struct vm_area_struct *vma,
309 pud_t * pud; 309 pud_t * pud;
310 pmd_t * pmd; 310 pmd_t * pmd;
311 pte_t * pte; 311 pte_t * pte;
312 spinlock_t *ptl;
312 313
313 if (unlikely(anon_vma_prepare(vma))) 314 if (unlikely(anon_vma_prepare(vma)))
314 goto out_sig; 315 goto out;
315 316
316 flush_dcache_page(page); 317 flush_dcache_page(page);
317 pgd = pgd_offset(mm, address); 318 pgd = pgd_offset(mm, address);
318
319 spin_lock(&mm->page_table_lock);
320 pud = pud_alloc(mm, pgd, address); 319 pud = pud_alloc(mm, pgd, address);
321 if (!pud) 320 if (!pud)
322 goto out; 321 goto out;
323 pmd = pmd_alloc(mm, pud, address); 322 pmd = pmd_alloc(mm, pud, address);
324 if (!pmd) 323 if (!pmd)
325 goto out; 324 goto out;
326 pte = pte_alloc_map(mm, pmd, address); 325 pte = pte_alloc_map_lock(mm, pmd, address, &ptl);
327 if (!pte) 326 if (!pte)
328 goto out; 327 goto out;
329 if (!pte_none(*pte)) { 328 if (!pte_none(*pte)) {
330 pte_unmap(pte); 329 pte_unmap_unlock(pte, ptl);
331 goto out; 330 goto out;
332 } 331 }
333 inc_mm_counter(mm, rss); 332 inc_mm_counter(mm, anon_rss);
334 lru_cache_add_active(page); 333 lru_cache_add_active(page);
335 set_pte_at(mm, address, pte, pte_mkdirty(pte_mkwrite(mk_pte( 334 set_pte_at(mm, address, pte, pte_mkdirty(pte_mkwrite(mk_pte(
336 page, vma->vm_page_prot)))); 335 page, vma->vm_page_prot))));
337 page_add_anon_rmap(page, vma, address); 336 page_add_anon_rmap(page, vma, address);
338 pte_unmap(pte); 337 pte_unmap_unlock(pte, ptl);
339 spin_unlock(&mm->page_table_lock);
340 338
341 /* no need for flush_tlb */ 339 /* no need for flush_tlb */
342 return; 340 return;
343out: 341out:
344 spin_unlock(&mm->page_table_lock);
345out_sig:
346 __free_page(page); 342 __free_page(page);
347 force_sig(SIGKILL, current); 343 force_sig(SIGKILL, current);
348} 344}
@@ -490,8 +486,7 @@ struct file *open_exec(const char *name)
490 int err; 486 int err;
491 struct file *file; 487 struct file *file;
492 488
493 nd.intent.open.flags = FMODE_READ; 489 err = path_lookup_open(name, LOOKUP_FOLLOW, &nd, FMODE_READ);
494 err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
495 file = ERR_PTR(err); 490 file = ERR_PTR(err);
496 491
497 if (!err) { 492 if (!err) {
@@ -504,7 +499,7 @@ struct file *open_exec(const char *name)
504 err = -EACCES; 499 err = -EACCES;
505 file = ERR_PTR(err); 500 file = ERR_PTR(err);
506 if (!err) { 501 if (!err) {
507 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); 502 file = nameidata_to_filp(&nd, O_RDONLY);
508 if (!IS_ERR(file)) { 503 if (!IS_ERR(file)) {
509 err = deny_write_access(file); 504 err = deny_write_access(file);
510 if (err) { 505 if (err) {
@@ -516,6 +511,7 @@ out:
516 return file; 511 return file;
517 } 512 }
518 } 513 }
514 release_open_intent(&nd);
519 path_release(&nd); 515 path_release(&nd);
520 } 516 }
521 goto out; 517 goto out;
@@ -1207,7 +1203,6 @@ int do_execve(char * filename,
1207 /* execve success */ 1203 /* execve success */
1208 security_bprm_free(bprm); 1204 security_bprm_free(bprm);
1209 acct_update_integrals(current); 1205 acct_update_integrals(current);
1210 update_mem_hiwater(current);
1211 kfree(bprm); 1206 kfree(bprm);
1212 return retval; 1207 return retval;
1213 } 1208 }