All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Valerie Aurora <vaurora@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: Fix use-after-free of vfsmount by mnt_drop_write()
Date: Tue, 23 Feb 2010 06:13:59 +0900	[thread overview]
Message-ID: <87pr3x6kiw.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <20100222205429.GH972@shell> (Valerie Aurora's message of "Mon, 22 Feb 2010 15:54:29 -0500")

Valerie Aurora <vaurora@redhat.com> writes:

>> Those might be assuming that the nd->path.mnt refcnt is keeped by
>> filp after nameidata_to_filp().
>> 
>> It's wrong if nameidata_to_filp() returned the error.  (nd->path and
>> filp are invalid)
>> 
>> Instead to use deep knowledge of nameidata_to_filp() internal, this
>> thinks the nd->path is invalid after nameidata_to_filp(). So, this
>> just take refcnt for mnt_want/drop_write().
>
> You might take a look at the patch I just posted:
>
> Subject: [RFC PATCH] VFS: Simplify truncate logic in do_filp_open()
>
> If that patch is correct, it will considerably simplify the second
> part of your patch.

[...]
>>  	/*
>> -	 * It is now safe to drop the mnt write
>> -	 * because the filp has had a write taken
>> -	 * on its behalf.
>> +	 * It is now safe to drop the mnt write because the filp has
>> +	 * had a write taken on its behalf. (NOTE: since O_TRUNC can
>> +	 * be used with O_RDONLY, this needs to cover truncate path)
>>  	 */
>> -	if (will_truncate)
>> -		mnt_drop_write(nd.path.mnt);
>> +	if (will_truncate) {
>> +		mnt_drop_write(mnt_writer);
>> +		mntput(mnt_writer);
>> +	}

Unfortunately, no. I already noted that we can't it simply. ;)

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

      reply	other threads:[~2010-02-22 21:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-22 18:03 [PATCH] vfs: Fix use-after-free of vfsmount by mnt_drop_write() OGAWA Hirofumi
2010-02-22 20:54 ` Valerie Aurora
2010-02-22 21:13   ` OGAWA Hirofumi [this message]

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=87pr3x6kiw.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vaurora@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.