Commit 17f79be93d95bb0e46bd08681ec9c9e601869c15
Committed by
Greg Kroah-Hartman
1 parent
e5bcac6147
Exists in
master
and in
20 other branches
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 <ebiederm@xmission.com> Cc: Glauber Costa <glommer@parallels.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff
fs/sysfs/dir.c
... | ... | @@ -329,10 +329,12 @@ |
329 | 329 | |
330 | 330 | /* The sysfs dirent has been moved to a different namespace */ |
331 | 331 | type = KOBJ_NS_TYPE_NONE; |
332 | - if (sd->s_parent) | |
332 | + if (sd->s_parent) { | |
333 | 333 | type = sysfs_ns_type(sd->s_parent); |
334 | - if (type && (sysfs_info(dentry->d_sb)->ns[type] != sd->s_ns)) | |
335 | - goto out_bad; | |
334 | + if (type != KOBJ_NS_TYPE_NONE && | |
335 | + sysfs_info(dentry->d_sb)->ns[type] != sd->s_ns) | |
336 | + goto out_bad; | |
337 | + } | |
336 | 338 | |
337 | 339 | mutex_unlock(&sysfs_mutex); |
338 | 340 | out_valid: |