Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4750156pxv; Tue, 27 Jul 2021 15:43:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrC2xs65ohxEe+PB/Rsq5tOFbDkruVTh7zqRRn575DJ2Q4RUKDmWOD4Cq1TWhxt9F/6owq X-Received: by 2002:a02:cf2e:: with SMTP id s14mr16828570jar.74.1627425793948; Tue, 27 Jul 2021 15:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627425793; cv=none; d=google.com; s=arc-20160816; b=Vb14+MV+NKm0Z4Nm8pTA6RR9R52t5Wv/1ZHj7pJD/UzUtL0caH4tjnn2qY1ZUxc/yw xdd02V3k5fFtgtovSuFkMyDOkNuLohPDIBRvds8e+ubuZmqMBse+Umfnjp0+pr2EIKgk Z4a5/vhcal6sHLGg5hyhtEKELScp2cjYeWmrX4w4hy9qSs5d8T/y9HUZAWY8WQgGzMbq jTkCVA9xwVg1lDDLYYoxlclxV2LmSwCuyetqDIuCnTD6TLkT24MNnrF3I5hQQ8HIocmS yiuaN6lG4EyDkwzSKeT7//TqmICMT1mRwr1gxUkmQ79pS9z5vnWdXpR9F4vTilTgjgG1 OHBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=jpgPD5RojPABcTMZULE6R7dcTBRiP3N2liSuqkAN1xY=; b=OeSAnERj7Ha9F7BX+S+vhaXfQgy84eeeloxNZL+3vIK4cx0lUgVGMWFxO/7RAFecxq QPeFNxKmnzO502q+RBUGCYvjMahh9imx8rE8Lc/NDgWu6rYbSa2RljDNyU/Wgm1WDAor GkjEQ7HE6qp8c91B9R+Z47b7KOeAJUR1js+Bwj+Yho+nSZcGIF6ClIjkDx7fq0pPJe89 DzmXN6nS+HsvZBbuF/utnyrk0e9XIWFWPOCuhfeulTxQoQfp6YBlPNXCKUqRM58TIfHp wGbCbRmN3imBxaMNYpVjYyp6oVZQW08AljcV+35YUu9myzLc8qz+HohnU2Emo8HOM3uJ SwAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LMyD+4Wc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si4687937ilu.28.2021.07.27.15.43.01; Tue, 27 Jul 2021 15:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LMyD+4Wc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232908AbhG0Wmr (ORCPT + 99 others); Tue, 27 Jul 2021 18:42:47 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:57098 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbhG0Wmr (ORCPT ); Tue, 27 Jul 2021 18:42:47 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7B63021E78; Tue, 27 Jul 2021 22:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627425765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jpgPD5RojPABcTMZULE6R7dcTBRiP3N2liSuqkAN1xY=; b=LMyD+4WcK7zDEfC+MFkXkbm4u0MMKJhZGrx3wykC6W5yYa8VGzDLSZnYVjS+rqnbFutBxS Ki/1B0Yv9VgP1fDcCv6AjsXN/IYBIUiat7mOfYOrEmHIDVditzSwcSBP1L7hYo0pQLFmxU RJ7sbGkalpJtTVIbeczlQ6GRrwSm8Dk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627425765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jpgPD5RojPABcTMZULE6R7dcTBRiP3N2liSuqkAN1xY=; b=gQl3LzlyrzrgRj1iFmV9PwaZk0LRCtv5DDnAgMdZXrYf/Oz4vtZfIj8oCo+gNm/pC1dgwc Mg4KAEtZ5NLNALBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 95D3013A5D; Tue, 27 Jul 2021 22:42:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hvjwFOKLAGGVVQAAMHmgww (envelope-from ); Tue, 27 Jul 2021 22:42:42 +0000 Subject: [PATCH 02/11] VFS: allow d_automount to create in-place bind-mount. From: NeilBrown To: Christoph Hellwig , Josef Bacik , "J. Bruce Fields" , Chuck Lever , Chris Mason , David Sterba , Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-btrfs@vger.kernel.org Date: Wed, 28 Jul 2021 08:37:45 +1000 Message-ID: <162742546549.32498.76256513179684921.stgit@noble.brown> In-Reply-To: <162742539595.32498.13687924366155737575.stgit@noble.brown> References: <162742539595.32498.13687924366155737575.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org finish_automount() prevents a mount trap from mounting a dentry onto itself, as this could cause a loop - repeatedly automounting. There is nothing intrinsically wrong with this arrangement, and the d_automount function can easily avoid the loop. btrfs will use it to expose subvols in the mount table. It may well be a problem to mount a dentry onto itself when it is already the root of the vfsmount, so narrow the test to only check that case. The test on mnt_sb is redundant and has been removed. path->mnt and path->dentry must have the same sb, so if m->mnt_root == dentry, then m->mnt_sb must be the same as path->mnt->mnt_sb. Signed-off-by: NeilBrown --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index ab4174a3c802..81b0f2b2e701 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2928,7 +2928,7 @@ int finish_automount(struct vfsmount *m, struct path *path) */ BUG_ON(mnt_get_count(mnt) < 2); - if (m->mnt_sb == path->mnt->mnt_sb && + if (m->mnt_root == path->mnt->mnt_root && m->mnt_root == dentry) { err = -ELOOP; goto discard;