Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp911035imj; Fri, 15 Feb 2019 08:49:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IZjFh+Okv1/aFWpiKAb56WRaW0qIHZAQ9EkMdu78GArt+xnDWXeZa72vj/0xucslu+J8VKa X-Received: by 2002:a17:902:bd0a:: with SMTP id p10mr10842112pls.322.1550249366756; Fri, 15 Feb 2019 08:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550249366; cv=none; d=google.com; s=arc-20160816; b=ebBWGJcvIlAFJSwgKWH5mfVGmzJeRbcsBFUk4TyRcArb1hcsZOhJRNgEldR34223qh f4AUfQNWfYua4gzvUjGDUCZgJX5dWBtYKjm+ivzkhwA23VMgg4+YKt6qaA+eXIAXUNgI po3XlJjlcKd+citzrYzOFz4WSTwhmxUMqcLEHXec3XDnm2OOSYzo1YpN9m2ztvrd9h3O UBlJuMLH6n/qHw50stY9EmrQ0SaY0rYoYHlLx8E4fOHE7j2ROYi5OT59TPlbMEA+Krbw 3qb9G5Pa+/myEp93ua4ZbjUJDnbuEK6PJJKPqt5AHBC/4G0tINZdFnzI0k0zVnRQzdtm G4Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=PmUfVVyCw1uqJJMqGsURW5T2l/yN3WQc/BHHD7X7jUY=; b=z1ioWWhQwI7XQvU6wISUv22Q+d2CHR2NrjkADdHj8Ph0qGu/a+AShrPZ2NODMxlf3B qbBvvb9qM/HDZvlW1N/5AVj+T5wvTlXq1tjL+hXfk1jBQoNvj92b9wIknGCP39c9VO0C t1el7Z/K9YkXGu4GcUCVqB4CFc4hFaa9fdeIOpz81BZUi9VAl3LK74ScQB31ZYJgnrXT PuA+LWQpee6s1bPVb6Amo3u9BPNibMiLSJp1G5DJPLQwkUfdDvEkwZRYRnbip1Cs27dD UYuKBljBuRqaunRvPiHKoMQazcE1txiy5N3Ur6709YjtIybgy6RrGsK4N3eM3lhxISPL nmmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d78si4679267pfj.261.2019.02.15.08.49.10; Fri, 15 Feb 2019 08:49:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391863AbfBOQIx (ORCPT + 99 others); Fri, 15 Feb 2019 11:08:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59314 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388365AbfBOQIw (ORCPT ); Fri, 15 Feb 2019 11:08:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43832C7966; Fri, 15 Feb 2019 16:08:52 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-129.rdu2.redhat.com [10.10.121.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 603C660C80; Fri, 15 Feb 2019 16:08:47 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [RFC PATCH 09/27] vfs: Allow mounting to other namespaces From: David Howells To: keyrings@vger.kernel.org, trond.myklebust@hammerspace.com, sfrench@samba.org Cc: linux-security-module@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, rgb@redhat.com, dhowells@redhat.com, linux-kernel@vger.kernel.org Date: Fri, 15 Feb 2019 16:08:46 +0000 Message-ID: <155024692658.21651.7276705643207668882.stgit@warthog.procyon.org.uk> In-Reply-To: <155024683432.21651.14153938339749694146.stgit@warthog.procyon.org.uk> References: <155024683432.21651.14153938339749694146.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Feb 2019 16:08:52 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently sys_move_mount() and sys_mount(MS_MOVE) prevent the caller from moving a mount into a namespace not their own. Relax this such that any mount can be mounted onto any given mountpoint provided that the source mount is either detached or the same namespace as the destination. This permits container namespaces to be built from the outside rather than from the inside. Signed-off-by: David Howells --- fs/namespace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 22cf4a8f8065..804601b6297c 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2627,12 +2627,10 @@ static int do_move_mount(struct path *old_path, struct path *new_path) ns = old->mnt_ns; err = -EINVAL; - /* The mountpoint must be in our namespace. */ - if (!check_mnt(p)) - goto out; - - /* The thing moved should be either ours or completely unattached. */ - if (attached && !check_mnt(old)) + /* The new mount must be either unattached or in the same namespace as + * the mountpoint. + */ + if (attached && old->mnt_ns != p->mnt_ns) goto out; if (!attached && !is_anon_ns(ns))