fix cgroup_do_mount() handling of failure exits
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 6 Jan 2019 16:41:29 +0000 (11:41 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 17 Jan 2019 16:52:49 +0000 (11:52 -0500)
commit399504e21a10be16dd1408ba0147367d9d82a10c
tree7762ae17e66c37d39687268eac7dd99965f2ba0a
parent1c7fc5cbc33980acd13d668f1c8f0313d6ae9fd8
fix cgroup_do_mount() handling of failure exits

same story as with last May fixes in sysfs (7b745a4e4051
"unfuck sysfs_mount()"); new_sb is left uninitialized
in case of early errors in kernfs_mount_ns() and papering
over it by treating any error from kernfs_mount_ns() as
equivalent to !new_ns ends up conflating the cases when
objects had never been transferred to a superblock with
ones when that has happened and resulting new superblock
had been dropped.  Easily fixed (same way as in sysfs
case).  Additionally, there's a superblock leak on
kernfs_node_dentry() failure *and* a dentry leak inside
kernfs_node_dentry() itself - the latter on probably
impossible errors, but the former not impossible to trigger
(as the matter of fact, injecting allocation failures
at that point *does* trigger it).

Cc: stable@kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/kernfs/mount.c
kernel/cgroup/cgroup.c