From: Badari Pulavarty <pbadari@us.ibm.com>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/6] 2.4.19-rc1 do_execve() stack reduction
Date: 10 Jan 2005 09:38:40 -0800 [thread overview]
Message-ID: <1105378720.4000.136.camel@dyn318077bld.beaverton.ibm.com> (raw)
In-Reply-To: <1105378550.4000.132.camel@dyn318077bld.beaverton.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: execv.patch --]
[-- Type: text/plain, Size: 2749 bytes --]
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;
}
next prev parent reply other threads:[~2005-01-10 18:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-10 17:35 [PATCH 0/6] 2.4.19-rc1 stack reduction patches Badari Pulavarty
2005-01-10 17:38 ` Badari Pulavarty [this message]
2005-01-10 17:39 ` [PATCH 2/6] 2.4.19-rc1 number() stack reduction Badari Pulavarty
2005-01-10 19:50 ` Kevin P. Fleming
2005-01-10 21:33 ` Badari Pulavarty
2005-01-10 21:29 ` Badari Pulavarty
2005-01-10 17:40 ` [PATCH 3/6] 2.4.19-rc1 nfs_lookup stack reduction patch Badari Pulavarty
2005-01-10 17:41 ` [PATCH 4/6] 2.4.19-rc1 nfs revalidate_inode() stack reduction patches Badari Pulavarty
2005-01-10 17:41 ` [PATCH 5/6] 2.4.19-rc1 rpc_call_sync() stack reduction patch Badari Pulavarty
2005-01-10 17:42 ` [PATCH 6/6] 2.4.19-rc1 xprt_sendmsg() " Badari Pulavarty
2005-01-11 7:39 ` [PATCH 0/6] 2.4.19-rc1 stack reduction patches Arjan van de Ven
2005-01-11 7:49 ` Marcelo Tosatti
2005-01-11 11:18 ` Arjan van de Ven
2005-01-11 10:17 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1105378720.4000.136.camel@dyn318077bld.beaverton.ibm.com \
--to=pbadari@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).