From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: Xiaotian Feng <xtfeng@gmail.com>
Cc: "Américo Wang" <xiyou.wangcong@gmail.com>,
"André Goddard Rosa" <andre.goddard@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Serge E . Hallyn" <serue@us.ibm.com>,
"Cedric Le Goater" <clg@fr.ibm.com>,
"Al Viro" <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] mqueue: fix mq_open() file descriptor leak on user-space processes
Date: Thu, 25 Feb 2010 21:17:15 +0800 [thread overview]
Message-ID: <20100225131715.GA3842@hack> (raw)
In-Reply-To: <7b6bb4a51002250249t7e4f03c9r6b2b9a8f348a29aa@mail.gmail.com>
On Thu, Feb 25, 2010 at 06:49:09PM +0800, Xiaotian Feng wrote:
>On Thu, Feb 25, 2010 at 2:59 PM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>> On Thu, Feb 25, 2010 at 12:25 PM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>>> On Thu, Feb 25, 2010 at 12:00 PM, Xiaotian Feng <xtfeng@gmail.com> wrote:
>>>> 2010/2/25 Américo Wang <xiyou.wangcong@gmail.com>:
>>>>> On Tue, Feb 23, 2010 at 3:04 PM, André Goddard Rosa
>>>>> <andre.goddard@gmail.com> wrote:
>>>>>> It can be triggered by the following test program:
>>>>>>
>>>>>
>>>>> <snip>
>>>>>
>>>>>>
>>>>>> When not running valgrind, user-space program segfaults trying to execute
>>>>>> strerror(errno). With valgrind, it executes successfully and prints the
>>>>>> 5 open files: stdin, stdout, stderr, pipe[0] and pipe[1].
>>>>>>
>>>>>> Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
>>>>>> ---
>>>>>
>>>>> The code has more than just this problem, could you please try
>>>>> my patch below?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> ---------------------------->
>>>>>
>>>>> Clean up the failure path of sys_mq_open().
>>>>>
>>>>> Reorder the goto labels;
>>>>> Rename 'upsem' to 'upunlock';
>>>>> Remove some unused labels;
>>>>> Fix some wrong goto path.
>>>>>
>>>>
>>>> I think it's wrong to move dput after mntput
>>>
>>> Oh, this is to say mntget() should be called before lookup_one_len(),
>>> the original code seems wrong again...
>>>
>>
>> How about the one below?
>
>This is definitely wrong,
>
> if (IS_ERR(filp)) {
> error = PTR_ERR(filp);
>- goto out_putfd;
>+ goto out;
> }
>
>filp is assigned by do_open or do_create in mqueue.c, take a look at
>the code, if do_open/do_create is failed, kernel is already dput &
>mntput...
>
Clearly the original code is a piece of sh*t.
next prev parent reply other threads:[~2010-02-25 13:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-23 7:04 [PATCH 0/6] Fix file descriptor leak on user-space processes and cleanup André Goddard Rosa
2010-02-23 7:04 ` [PATCH 1/6] mqueue: remove unneeded info->messages initialization André Goddard Rosa
2010-02-23 7:04 ` [PATCH 2/6] mqueue: apply mathematics distributivity on mq_bytes calculation André Goddard Rosa
2010-02-23 7:04 ` [PATCH 3/6] mqueue: simplify do_open() error handling André Goddard Rosa
2010-02-23 7:04 ` [PATCH 4/6] mqueue: only set error codes if they are really necessary André Goddard Rosa
2010-02-23 7:04 ` [PATCH 5/6] mqueue: fix typo "failues" -> "failures" André Goddard Rosa
2010-02-23 7:04 ` [PATCH 6/6] mqueue: fix mq_open() file descriptor leak on user-space processes André Goddard Rosa
2010-02-25 3:35 ` Américo Wang
2010-02-25 4:00 ` Xiaotian Feng
2010-02-25 4:25 ` Américo Wang
2010-02-25 6:59 ` Américo Wang
2010-02-25 10:49 ` Xiaotian Feng
2010-02-25 13:17 ` Américo Wang [this message]
2010-02-25 13:40 ` [Patch] mqueue: fix the bad code in sys_mq_open() Américo Wang
2010-02-25 15:41 ` André Goddard Rosa
2010-02-25 16:15 ` Américo Wang
2010-03-03 19:54 ` Al Viro
2010-02-25 10:56 ` [PATCH 6/6] mqueue: fix mq_open() file descriptor leak on user-space processes Xiaotian Feng
2010-02-24 22:01 ` [PATCH 0/6] Fix file descriptor leak on user-space processes and cleanup Andrew Morton
2010-02-25 15:52 ` André Goddard Rosa
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=20100225131715.GA3842@hack \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andre.goddard@gmail.com \
--cc=clg@fr.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xtfeng@gmail.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