From: WANG Cong <xiyou.wangcong@gmail.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: WANG Cong <xiyou.wangcong@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, WANG Cong <wangcong@zeuux.org>
Subject: Re: [Patch 3/9] fs/compat.c: fix resource leaks and wrong goto's
Date: Mon, 12 May 2008 11:46:09 +0800 [thread overview]
Message-ID: <20080512034609.GB2572@hacking> (raw)
In-Reply-To: <20080510203543.GJ13907@ZenIV.linux.org.uk>
On Sat, May 10, 2008 at 09:35:43PM +0100, Al Viro wrote:
>On Sat, May 10, 2008 at 08:21:11PM +0100, Al Viro wrote:
>> On Thu, May 08, 2008 at 09:52:28PM +0800, WANG Cong wrote:
>> > Use free_arg_pages() to free the pages allocated by copy_strings_kernel()
>> > on failure. And fix some related wrong goto pathes.
>>
>> Kinda; free_arg_pages() is needed here, but there's no need to mess with
>> goto - just put it under out:
>>
>> Note that it's essentially just a part of freeing bprm; it's _not_ a "clean
>> collected strings, so that we could add new ones".
>
>FWIW, I'd suggest this:
Hmm, looks fine. But, see below.
>
>diff --git a/fs/compat.c b/fs/compat.c
>index 332a869..ed43e17 100644
>--- a/fs/compat.c
>+++ b/fs/compat.c
>@@ -1405,7 +1405,7 @@ int compat_do_execve(char * filename,
> /* execve success */
> security_bprm_free(bprm);
> acct_update_integrals(current);
>- kfree(bprm);
>+ free_bprm(bprm);
> return retval;
> }
>
>@@ -1424,7 +1424,7 @@ out_file:
> }
>
> out_kfree:
>- kfree(bprm);
>+ free_bprm(bprm);
>
> out_ret:
> return retval;
>diff --git a/fs/exec.c b/fs/exec.c
>index aeaa979..ad545b0 100644
>--- a/fs/exec.c
>+++ b/fs/exec.c
>@@ -1251,6 +1251,12 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
>
> EXPORT_SYMBOL(search_binary_handler);
>
>+void free_bprm(struct linux_binprm *bprm)
>+{
>+ free_arg_pages(bprm);
>+ kfree(bprm);
>+}
>+
> /*
> * sys_execve() executes a new program.
> */
>@@ -1320,17 +1326,15 @@ int do_execve(char * filename,
> retval = search_binary_handler(bprm,regs);
> if (retval >= 0) {
> /* execve success */
>- free_arg_pages(bprm);
> security_bprm_free(bprm);
> acct_update_integrals(current);
>- kfree(bprm);
>+ free_bprm(bprm);
> if (displaced)
> put_files_struct(displaced);
> return retval;
> }
>
> out:
>- free_arg_pages(bprm);
Why just drop this? No need to call free_bprm()?
--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.
next prev parent reply other threads:[~2008-05-12 3:48 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 13:52 [Patch 0/9] Fix resource leaks for exec related stuffs WANG Cong
2008-05-08 13:52 ` [Patch 1/9] fs/exec.c: export free_arg_pages WANG Cong
2008-05-10 19:12 ` Al Viro
2008-05-12 3:59 ` WANG Cong
2008-05-08 13:52 ` [Patch 2/9] fs/exec.c: fix resource leaks and wrong goto's WANG Cong
2008-05-10 19:16 ` Al Viro
2008-05-08 13:52 ` [Patch 3/9] fs/compat.c: " WANG Cong
2008-05-10 19:21 ` Al Viro
2008-05-10 20:35 ` Al Viro
2008-05-12 3:46 ` WANG Cong [this message]
2008-05-12 4:05 ` Al Viro
2008-05-08 13:52 ` [Patch 4/9] fs/binfmt_script.c: fix resource leaks WANG Cong
2008-05-10 19:24 ` Al Viro
2008-05-08 13:52 ` [Patch 5/9] fs/binfmt_em86.c: " WANG Cong
2008-05-10 19:25 ` Al Viro
2008-05-12 3:53 ` WANG Cong
2008-05-08 13:52 ` [Patch 6/9] fs/binfmt_misc.c: " WANG Cong
2008-05-10 19:25 ` Al Viro
2008-05-08 13:52 ` [Patch 7/9] fs/exec.c: fix wrong return value of prepare_binprm() WANG Cong
2008-05-10 19:31 ` Al Viro
2008-05-12 3:56 ` WANG Cong
2008-05-12 4:01 ` Al Viro
2008-05-12 4:15 ` WANG Cong
2008-05-12 4:37 ` Al Viro
2008-05-12 4:52 ` WANG Cong
2008-05-08 13:52 ` [Patch 8/9] fs/binfmt_elf.c: fix wrong return values WANG Cong
2008-05-08 13:52 ` [Patch 9/9] fs/exec.c: fix a wrong goto path WANG Cong
2008-05-10 19:37 ` Al Viro
2008-05-12 3:51 ` WANG Cong
2008-05-12 3:58 ` Al Viro
2008-05-10 20:47 ` [Patch 0/9] Fix resource leaks for exec related stuffs Al Viro
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=20080512034609.GB2572@hacking \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=wangcong@zeuux.org \
/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