Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A5854A2A77 for ; Mon, 12 Oct 2026 15:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791819739; cv=none; b=UJfyM9oWxyyko/4fCXNwTBFIwobvcPl+Vo/+gZ66bih1wnwEzK9JL5sD4Z1EZ+STKU2b2O2TcH+y+ZrpxgxnCkE719leFwPfrpIlba7RshP113yRg5pT/L0HtS64cUMOQU3Nnq9Zm8N1u2OScbeKbNlGi0sE0in1gJ/VOqBkK6I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791819739; c=relaxed/simple; bh=1398/IgX+kbN8jrMQL2qrytKhTp1mhkbl43Vcu/Ytpg=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=GsZXh+2YfI9xVrZJivR7H0Mq3YCwzLSHiCl6bhblqH+Uu3+4RChrtegs3jc4VE8rfdXy5PlZLhloZzOAo7ewUezQWax7W4HbyoPlnIxShCGwQJI+WLI1dDaBLqCLmjFzJGjiwNZbdG686rYtoyBZ+Nm0RgrQ2HQxjYKpCMCNjBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fexbNlCo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fexbNlCo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 510AD1F0089B; Mon, 12 Oct 2026 15:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791819737; bh=1dTRjVikjYSzPK40Ishvs0khlw6LKMdHiqbnLhycphA=; h=Subject:To:Cc:From:Date; b=fexbNlCoM8dTbJgfz7wDQauGL1mLnSdDcfijJhsU0f48nZJfG7ViNudAuUl82vknF KlzuAEhpd5hV/2JWN0mJBNkASV8hgzBlr0ChCy58s1WKmtYpIjDDVGRB9Y5je2xTme JwTZ5CkbnxEcXHEKdNbIm+YqJ/LHlUXlr+MKDkjs= Subject: FAILED: patch "[PATCH] namespace: don't copy an unmounted mount tree" failed to apply to 5.15-stable tree To: brauner@kernel.org Cc: From: Date: Mon, 12 Oct 2026 17:40:01 +0200 Message-ID: <2026101201-arrogance-designer-e9e2@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 8bacbf6be959973b28b691713a872c12eae69eec # git commit -s git send-email --to '' --in-reply-to '2026101201-arrogance-designer-e9e2@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From 8bacbf6be959973b28b691713a872c12eae69eec Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 26 Sep 2026 15:44:27 +0200 Subject: [PATCH] namespace: don't copy an unmounted mount tree may_copy_tree() accepts a mount whose root is an nsfs or pidfs file before it checks whether that mount is mounted. This exception exists for nsfs and pidfs mounts. They are part of no mount namespace so neither check_mnt() nor is_mounted() would let them through and bind-mounting a nsfsfd or a pidfd wouldn't work. Problem is that exception also admits a bind mount of such a file when it was lazily unmounted and is only kept alive by a file descriptor: mount --bind /proc/self/ns/net /tmp/x exec 3< /tmp/x umount -l /tmp/x mount --rbind /proc/self/fd/3 /tmp/y With MS_REC or AT_RECURSIVE copy_tree() doesn't stop at the unmounted mount. It copies every mount that stayed attached to it as well. So if you have a bunch of overmounts over the nsfsfd or the pidfd the whole unmounted stack is copied. That's a bug. So refuse to walk an unmounted tree. Copying its root alone stays possible. So a bind mount of a namespace that is gone can still be recreated from a file descriptor on the old one. The file descriptor pins that mount and its root and __has_locked_children() only reads the direct children which don't leave the parent's list without namespace_sem. The internal mounts carry MNT_NS_INTERNAL instead of NULL and are still walked. Copying an unmounted tree recursively fails with EINVAL. Fixes: e149ed2b805f ("take the targets of /proc/*/ns/* symlinks to separate fs") Fixes: ef4144ac2dec ("pidfs: allow bind-mounts") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260926-work-mount-fixes-2-v1-4-f357abf3d17b@kernel.org Signed-off-by: Christian Brauner (Amutable) diff --git a/fs/namespace.c b/fs/namespace.c index 6d4ecde682df..c7e252eb249e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3007,6 +3007,9 @@ static struct mount *__do_loopback(const struct path *old_path, if (!may_copy_tree(old_path)) return ERR_PTR(-EINVAL); + if (recurse && !old->mnt_ns) + return ERR_PTR(-EINVAL); + if (!recurse && __has_locked_children(old, old_path->dentry)) return ERR_PTR(-EINVAL);