From patchwork Fri Apr 3 01:56:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 6153221 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 277CF9F2EC for ; Fri, 3 Apr 2015 02:01:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 407C220379 for ; Fri, 3 Apr 2015 02:01:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 576742035E for ; Fri, 3 Apr 2015 02:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753349AbbDCCBm (ORCPT ); Thu, 2 Apr 2015 22:01:42 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:45111 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbbDCCBm (ORCPT ); Thu, 2 Apr 2015 22:01:42 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1YdqvV-0002y0-QV; Thu, 02 Apr 2015 20:01:41 -0600 Received: from 70-59-163-10.omah.qwest.net ([70.59.163.10] helo=x220.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1Ydqux-0003Lp-OR; Thu, 02 Apr 2015 20:01:08 -0600 From: "Eric W. Biederman" To: Linux Containers Cc: , "Serge E. Hallyn" , Andy Lutomirski , Richard Weinberger , Andrey Vagin , Al Viro , Jann Horn , Willy Tarreau , Omar Sandoval Date: Thu, 2 Apr 2015 20:56:22 -0500 Message-Id: <1428026183-14879-18-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <87a8yqou41.fsf_-_@x220.int.ebiederm.org> References: <87a8yqou41.fsf_-_@x220.int.ebiederm.org> X-XM-AID: U2FsdGVkX19z6cxzAacjSQ7khlXHxtDsqMVZVHAxmPo= X-SA-Exim-Connect-IP: 70.59.163.10 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Linux Containers X-Spam-Relay-Country: X-Spam-Timing: total 280 ms - load_scoreonly_sql: 0.07 (0.0%), signal_user_changed: 4.5 (1.6%), b_tie_ro: 3.3 (1.2%), parse: 1.03 (0.4%), extract_message_metadata: 15 (5.4%), get_uri_detail_list: 2.3 (0.8%), tests_pri_-1000: 6 (2.2%), tests_pri_-950: 1.37 (0.5%), tests_pri_-900: 1.17 (0.4%), tests_pri_-400: 21 (7.6%), check_bayes: 20 (7.1%), b_tokenize: 7 (2.4%), b_tok_get_all: 6 (2.1%), b_comp_prob: 1.97 (0.7%), b_tok_touch_all: 2.8 (1.0%), b_finish: 0.88 (0.3%), tests_pri_0: 221 (78.8%), tests_pri_500: 5 (1.8%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH review 18/19] vfs: Handle mounts whose parents are unreachable from their mountpoint X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Add a mount flag MNT_UNREACHABLE_PARENT to mark mounts that can not reach their parent mount's root from their mountpoint. - In follup_up and follow_up_rcu don't follow up if the current mount's mountpoint can not reach the parent mount's root. - In prepend_path and it's callers in the d_path family don't follow to the parent mount if the current mount's mountpoint can not reach the parent mount's root. Signed-off-by: "Eric W. Biederman" --- fs/dcache.c | 3 ++- fs/namei.c | 4 ++-- include/linux/mount.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index e07eb03f6de6..cae4a42c1846 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2893,7 +2893,8 @@ restart: if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { struct mount *parent = ACCESS_ONCE(mnt->mnt_parent); /* Global root? */ - if (mnt != parent) { + if ((mnt != parent) && + !(mnt->mnt.mnt_flags & MNT_UNREACHABLE_PARENT)) { dentry = ACCESS_ONCE(mnt->mnt_mountpoint); mnt = parent; vfsmnt = &mnt->mnt; diff --git a/fs/namei.c b/fs/namei.c index ec09c90089a9..31a9c9a5787d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -938,7 +938,7 @@ static int follow_up_rcu(struct path *path) struct dentry *mountpoint; parent = mnt->mnt_parent; - if (&parent->mnt == path->mnt) + if ((mnt->mnt.mnt_flags & MNT_UNREACHABLE_PARENT) || (parent == mnt)) return 0; mountpoint = mnt->mnt_mountpoint; path->dentry = mountpoint; @@ -964,7 +964,7 @@ int follow_up(struct path *path) read_seqlock_excl(&mount_lock); parent = mnt->mnt_parent; - if (parent == mnt) { + if ((mnt->mnt.mnt_flags & MNT_UNREACHABLE_PARENT) || (parent == mnt)) { read_sequnlock_excl(&mount_lock); return 0; } diff --git a/include/linux/mount.h b/include/linux/mount.h index 778d7cf65b9a..3249da1af130 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -63,6 +63,7 @@ struct mnt_namespace; #define MNT_MARKED 0x4000000 #define MNT_UMOUNT 0x8000000 #define MNT_VIOLATED 0x10000000 +#define MNT_UNREACHABLE_PARENT 0x20000000 struct vfsmount { struct dentry *mnt_root; /* root of the mounted tree */