lkml.org 
[lkml]   [2005]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 1/6] 2.4.19-rc1 do_execve() stack reduction
From
Date

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
--- linux-2.4.29-rc1.org/fs/exec.c 2005-01-07 07:39:06.000000000 -0800
+++ linux-2.4.29-rc1/fs/exec.c 2005-01-10 00:28:52.000000000 -0800
@@ -930,7 +930,7 @@ int search_binary_handler(struct linux_b
*/
int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs)
{
- struct linux_binprm bprm;
+ struct linux_binprm *bprm;
struct file *file;
int retval;
int i;
@@ -941,60 +941,69 @@ int do_execve(char * filename, char ** a
if (IS_ERR(file))
return retval;

- bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
- memset(bprm.page, 0, MAX_ARG_PAGES*sizeof(bprm.page[0]));
+ bprm = kmalloc(sizeof(struct linux_binprm), GFP_KERNEL);
+ if (!bprm) {
+ return -ENOMEM;
+ }
+
+ bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
+ memset(bprm->page, 0, MAX_ARG_PAGES*sizeof(bprm->page[0]));

- bprm.file = file;
- bprm.filename = filename;
- bprm.sh_bang = 0;
- bprm.loader = 0;
- bprm.exec = 0;
- if ((bprm.argc = count(argv, bprm.p / sizeof(void *))) < 0) {
+ bprm->file = file;
+ bprm->filename = filename;
+ bprm->sh_bang = 0;
+ bprm->loader = 0;
+ bprm->exec = 0;
+ if ((bprm->argc = count(argv, bprm->p / sizeof(void *))) < 0) {
allow_write_access(file);
fput(file);
- return bprm.argc;
+ retval = bprm->argc;
+ goto free_bprm;
}

- if ((bprm.envc = count(envp, bprm.p / sizeof(void *))) < 0) {
+ if ((bprm->envc = count(envp, bprm->p / sizeof(void *))) < 0) {
allow_write_access(file);
fput(file);
- return bprm.envc;
+ retval = bprm->envc;
+ goto free_bprm;
}

- retval = prepare_binprm(&bprm);
+ retval = prepare_binprm(bprm);
if (retval < 0)
goto out;

- retval = copy_strings_kernel(1, &bprm.filename, &bprm);
+ retval = copy_strings_kernel(1, &bprm->filename, bprm);
if (retval < 0)
goto out;

- bprm.exec = bprm.p;
- retval = copy_strings(bprm.envc, envp, &bprm);
+ bprm->exec = bprm->p;
+ retval = copy_strings(bprm->envc, envp, bprm);
if (retval < 0)
goto out;

- retval = copy_strings(bprm.argc, argv, &bprm);
+ retval = copy_strings(bprm->argc, argv, bprm);
if (retval < 0)
goto out;

- retval = search_binary_handler(&bprm,regs);
+ retval = search_binary_handler(bprm,regs);
if (retval >= 0)
/* execve success */
- return retval;
+ goto free_bprm;

out:
/* Something went wrong, return the inode and free the argument pages*/
- allow_write_access(bprm.file);
- if (bprm.file)
- fput(bprm.file);
+ allow_write_access(bprm->file);
+ if (bprm->file)
+ fput(bprm->file);

for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
- struct page * page = bprm.page[i];
+ struct page * page = bprm->page[i];
if (page)
__free_page(page);
}

+free_bprm:
+ kfree(bprm);
return retval;
}
\
 
 \ /
  Last update: 2005-03-22 14:09    [W:0.075 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site