From: Andrew Morton Date: Mon, 9 Jul 2012 23:13:36 +0000 (-0700) Subject: sysfs: fail dentry revalidation after namespace change fix X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=17f79be93d95bb0e46bd08681ec9c9e601869c15;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Glauber Costa Cc: Tejun Heo Signed-off-by: Andrew Morton Acked-by: Serge E. Hallyn Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index c0bf38a21caa..1cdfb53199aa 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -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: