lkml.org 
[lkml]   [2008]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/3] sysfs: Remove lock ordering violation in sysfs_chmod_file.
Dave Hansen <dave@linux.vnet.ibm.com> writes:

> On Tue, 2008-10-07 at 03:49 -0700, Eric W. Biederman wrote:
>> It is a wee bit subtle but sysfs_get_dentry grabs inode->i_mutex.
>> of potentially all of the parents of sd. So I can not hold
>> the inode mutex of the directory while it is called.
>
> Hi Eric,
>
> This patch looks good to me. In my quest to parse exactly what was
> going on, I rewrote a description of the patch. Could you look over
> this and see if I'm on target?

It sounds like you are on target.

> Before this patch, inode->i_mutex is held in order to keep the inode's
> mode and ctime from changing out underneath us. If we didn't do this,
> you could potentially get garbage when reading them out of the old
> inode. We calculated these new permissions once since it is redundant
> to do it several times.

Yes. updates to mtime and ctime need to be serialized by holding
the inode semaphore.

> We also need to perform a sysfs_get_dentry() operation on the
> sysfs_dirent in order to find all the dentries on each sb.

To find the dentry for a particular sb.

> This needs
> to be performed once for each sb in which the inode appears. "[B]ut
> sysfs_get_dentry grabs inode->i_mutex. of potentially all of the parents
> of sd. So I can not hold the inode mutex of the directory while it is
> called."

Yes.

> This patch drops the inode->i_mutex over the entire "for each
> sysfs_dirent" loop. It, instead, reacquires and drops it each time we
> need to calculate the new mode/ctime for the target dentries. It does
> this away from the sysfs_get_dentry() call now.

Yes.

Eric


\
 
 \ /
  Last update: 2008-10-08 00:39    [W:0.073 / U:4.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site