All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitri Monakhov <dmonakhov@openvz.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfs: Fix possible chmod/truncate race condition.
Date: Mon, 27 Oct 2008 10:57:15 +0300	[thread overview]
Message-ID: <m31vy2bhd0.fsf@dmon-lap.sw.ru> (raw)
In-Reply-To: <20081026203713.c00e69db.akpm@linux-foundation.org> (Andrew Morton's message of "Sun\, 26 Oct 2008 20\:37\:13 -0700")

Andrew Morton <akpm@linux-foundation.org> writes:

> On Wed, 15 Oct 2008 23:35:27 +0400 Dmitri Monakhov <dmonakhov@openvz.org> wrote:
>
>> 
>> Signed-off-by: Dmitri Monakhov <dmonakhov@openvz.org>
>> ---
>>  fs/open.c |    3 +--
>>  1 files changed, 1 insertions(+), 2 deletions(-)
>> 
>> diff --git a/fs/open.c b/fs/open.c
>> index 07da935..3423b94 100644
>> --- a/fs/open.c
>> +++ b/fs/open.c
>> @@ -214,10 +214,9 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
>>  		newattrs.ia_valid |= ATTR_FILE;
>>  	}
>>  
>> +	mutex_lock(&dentry->d_inode->i_mutex);
>>  	/* Remove suid/sgid on truncate too */
>>  	newattrs.ia_valid |= should_remove_suid(dentry);
>> -
>> -	mutex_lock(&dentry->d_inode->i_mutex);
>>  	err = notify_change(dentry, &newattrs);
>>  	mutex_unlock(&dentry->d_inode->i_mutex);
>>  	return err;
>
> OK, I give up.  What race?
i_mode read not protected by i_mutex in should_remove_suid() and we
may have race condition with chown(). Sorry, seems I've been too crazy
about this. The truth is:
1: No one will call truncate() and chown() concurrently.
2: This race is still possible regardless to this fix.

      reply	other threads:[~2008-10-27  7:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 19:35 [PATCH] vfs: Fix possible chmod/truncate race condition Dmitri Monakhov
2008-10-27  3:37 ` Andrew Morton
2008-10-27  7:57   ` Dmitri Monakhov [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=m31vy2bhd0.fsf@dmon-lap.sw.ru \
    --to=dmonakhov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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 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.