sysfs: fail dentry revalidation after namespace change fix

don't assume that KOBJ_NS_TYPE_NONE==0.  Also save a test-n-branch.

Cc: Eric W. Biederman <[email protected]>
Cc: Glauber Costa <[email protected]>
Cc: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Serge E. Hallyn <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Andrew Morton 2012-07-09 16:13:36 -07:00 • committed by Greg Kroah-Hartman
commit 17f79be93d

View file

@ -329,10 +329,12 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
/* The sysfs dirent has been moved to a different namespace */
type = KOBJ_NS_TYPE_NONE;
if (sd->s_parent)
if (sd->s_parent) {
type = sysfs_ns_type(sd->s_parent);
if (type && (sysfs_info(dentry->d_sb)->ns[type] != sd->s_ns))
goto out_bad;
if (type != KOBJ_NS_TYPE_NONE &&
sysfs_info(dentry->d_sb)->ns[type] != sd->s_ns)
goto out_bad;
}
mutex_unlock(&sysfs_mutex);
out_valid: