* [PATCH] vfs: Fix possible chmod/truncate race condition.
@ 2008-10-15 19:35 Dmitri Monakhov
2008-10-27 3:37 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Dmitri Monakhov @ 2008-10-15 19:35 UTC (permalink / raw)
To: linux-kernel
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;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vfs: Fix possible chmod/truncate race condition.
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
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2008-10-27 3:37 UTC (permalink / raw)
To: Dmitri Monakhov; +Cc: linux-kernel
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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vfs: Fix possible chmod/truncate race condition.
2008-10-27 3:37 ` Andrew Morton
@ 2008-10-27 7:57 ` Dmitri Monakhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitri Monakhov @ 2008-10-27 7:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-27 7:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox