From fd6742bd383021c232c71c4bbb2a9f9cb4925fcd Mon Sep 17 00:00:00 2001
From: Eric W. Biederman <ebiederm@redhat.com>
Date: Wed, 21 Jun 2017 12:35:25 -0400
Subject: [PATCH 61136/74394] [fs] mntns: Remove incorrect put_mnt_ns

Message-id: <gvsvanp1pte.fsf_-_@ebiederm.remote.csb>
Patchwork-id: 180030
O-Subject: [RHEL7.4 BZ1463072 PATCH] mntns: Remove incorrect put_mnt_ns
Bugzilla: 1463072
RH-Acked-by: Oleg Nesterov <oleg@redhat.com>
RH-Acked-by: Miklos Szeredi <mszeredi@redhat.com>

When the unprivileged mntns support was rebased because of
5a910408af72 ("[fs] fold dup_mnt_ns() into its only surviving caller")
the need for calling put_mnt_ns disappeared.  Unfortunately I missed
that fact.

Now unshare -Urm called several times, results in a kernel oops,
and anyone can do this.

Fix this by removing the unnecessary line of code.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1463072
Upstream Status: RHEL specific
Build Info: https://brewweb.devel.redhat.com/taskinfo?taskID=13486016
Testing: https://beaker.engineering.redhat.com/jobs/1915441
Testing: Chao Ye <cye@redhat.com> verified that the code (essentially
         "unshare -Urm") that was triggering kernel oopses and hangs no longer
         triggers them with this patch.

Fixes: 0c6649509d63 ("[fs] mnt: Move unprivileged use of the mntns to tech preview")
Signed-off-by: "Eric W. Biederman" <ebiederm@redhat.com>
Signed-off-by: Rafael Aquini <aquini@redhat.com>
---
 fs/namespace.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index b19b93c..d21098c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2816,7 +2816,6 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	if (user_ns != &init_user_ns) {
 		static int __read_mostly called_mark_tech_preview = 0;
 		if (!enable_unpriv_mnt_ns_creation) {
-			put_mnt_ns(ns);
 			return ERR_PTR(-EPERM);
 		}
 		if (!called_mark_tech_preview &&
-- 
1.7.1

