Skip to content

Commit 0748e55

Browse files
author
Al Viro
committed
userns and mnt_idmap leak in open_tree_attr(2)
Once want_mount_setattr() has returned a positive, it does require finish_mount_kattr() to release ->mnt_userns. Failing do_mount_setattr() does not change that. As the result, we can end up leaking userns and possibly mnt_idmap as well. Fixes: c4a1682 ("fs: add open_tree_attr()") Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent ce7df19 commit 0748e55

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fs/namespace.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,16 +5307,12 @@ SYSCALL_DEFINE5(open_tree_attr, int, dfd, const char __user *, filename,
53075307
kattr.kflags |= MOUNT_KATTR_RECURSE;
53085308

53095309
ret = wants_mount_setattr(uattr, usize, &kattr);
5310-
if (ret < 0)
5311-
return ret;
5312-
5313-
if (ret) {
5310+
if (ret > 0) {
53145311
ret = do_mount_setattr(&file->f_path, &kattr);
5315-
if (ret)
5316-
return ret;
5317-
53185312
finish_mount_kattr(&kattr);
53195313
}
5314+
if (ret)
5315+
return ret;
53205316
}
53215317

53225318
fd = get_unused_fd_flags(flags & O_CLOEXEC);

0 commit comments

Comments
 (0)