Received: by 10.213.65.68 with SMTP id h4csp1314781imn; Sat, 24 Mar 2018 09:14:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELtaddN+xs1uyEDU/WYY2yMWB7h/i1N3ooeIEvpB43i8pm936IEJ8Ufk6s9UxcS9nNMkV7SW X-Received: by 10.99.151.74 with SMTP id d10mr24524172pgo.219.1521908050229; Sat, 24 Mar 2018 09:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521908050; cv=none; d=google.com; s=arc-20160816; b=JII2TiaEK35JGHwf/91QLYzd7JWh46VDZMwBLOMG6HOu235297axRh2P/T5ExAbd+E VrmKzGvSIffIlaIBsc12RLjbatseYmCtiNQLt6DiL+bEiyoYHUS2P/IBEkwU2q0IIrMh PyDl6Jae2s80CwarKhHzIQNYtQG2rb6UutZmrk+sS2tDP5z35V4QN0Am02Drg7gtfKaT xO7lVPfY+BUYkGfnSXD24sK2Ttt9JmgiuZcxQld6R7VwjPzBrQSu08RI8Zm5gcwy/3tn zbgAbHoZHydNMMSJm+kwFFb983s474z7DbgckoYsJv6+IP8QeRcuKRilTt4BtiPOiOwT iPCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=7kZ8otZhhanGOm30MFxKiaRNGVfi8NYyU8Jxu4mbBvE=; b=FSPP61LFl4D2ZB0kacPyKSfcmeRZs8AlEDAe38grukvCp/DXd5WrfOb6isi/8viS6H WbnrFwwzIK+3wlBITX6L8sAdXNjhD6ngAUD1jZQ59NMkopjkLrVHzStWnFxup8OfANyh QLOeHj9JxldgbjauyBNWQg+sFhqfHf7pUWsifMVymwkCZR48FQhs7QwsrL9EVBsghtcw XcGdZlY10IT6USk5+gHHMcosYMeVLuySpkL3gy8QaKUCEMuHtRJm1tXXwXnKqFlElnPo LJSixRfpaqBIqA5yDaYr5MnwWeG1c7pXI0hmc7AlYWCrm8wxRj3CYKF5/Ry9DVfsPvSN EfMw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si9790631plb.366.2018.03.24.09.13.55; Sat, 24 Mar 2018 09:14:10 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752499AbeCXQND (ORCPT + 99 others); Sat, 24 Mar 2018 12:13:03 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:35914 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752439AbeCXQNC (ORCPT ); Sat, 24 Mar 2018 12:13:02 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ezlmv-0000HR-1K; Sat, 24 Mar 2018 10:13:01 -0600 Received: from 97-119-121-173.omah.qwest.net ([97.119.121.173] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1ezlmt-0003N1-W3; Sat, 24 Mar 2018 10:13:00 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: Aleksa Sarai , linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org References: <20180323060457.sxgsd3j2obi33fyw@gordon> <87k1u3ti9e.fsf@xmission.com> <87fu4qo4ff.fsf_-_@xmission.com> <20180323231511.GK30522@ZenIV.linux.org.uk> Date: Sat, 24 Mar 2018 11:12:02 -0500 In-Reply-To: <20180323231511.GK30522@ZenIV.linux.org.uk> (Al Viro's message of "Fri, 23 Mar 2018 23:15:11 +0000") Message-ID: <87in9ljvvx.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1ezlmt-0003N1-W3;;;mid=<87in9ljvvx.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.121.173;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18ibURohPQswukymQDZ/wukB2YAt5v2c9w= X-SA-Exim-Connect-IP: 97.119.121.173 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa03.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, XMNoVowels,XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Al Viro X-Spam-Relay-Country: X-Spam-Timing: total 595 ms - load_scoreonly_sql: 0.21 (0.0%), signal_user_changed: 5 (0.9%), b_tie_ro: 3.2 (0.5%), parse: 4.7 (0.8%), extract_message_metadata: 30 (5.1%), get_uri_detail_list: 3.3 (0.5%), tests_pri_-1000: 12 (2.1%), tests_pri_-950: 2.7 (0.5%), tests_pri_-900: 2.1 (0.3%), tests_pri_-400: 33 (5.5%), check_bayes: 30 (5.1%), b_tokenize: 12 (2.0%), b_tok_get_all: 8 (1.3%), b_comp_prob: 4.5 (0.8%), b_tok_touch_all: 2.4 (0.4%), b_finish: 0.87 (0.1%), tests_pri_0: 453 (76.1%), check_dkim_signature: 1.17 (0.2%), check_dkim_adsp: 5 (0.9%), tests_pri_500: 44 (7.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/2] fs: Extend mount_ns with support for a fast namespace to vfsmount function X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro writes: > On Fri, Mar 23, 2018 at 04:41:40PM -0500, Eric W. Biederman wrote: > >> struct dentry *mount_ns(struct file_system_type *fs_type, >> int flags, void *data, void *ns, struct user_namespace *user_ns, >> + struct vfsmount *(*ns_to_mnt)(void *ns), >> int (*fill_super)(struct super_block *, void *, int)) >> { >> struct super_block *sb; >> - >> + int (*test_super)(struct super_block *, void *) = ns_test_super; >> /* Don't allow mounting unless the caller has CAP_SYS_ADMIN >> * over the namespace. >> */ >> if (!(flags & SB_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN)) >> return ERR_PTR(-EPERM); >> >> - sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags, >> - user_ns, ns); >> + if (ns_to_mnt) { >> + test_super = NULL; >> + if (!(flags & SB_KERNMOUNT)) { >> + struct vfsmount *m = ns_to_mnt(ns); >> + if (IS_ERR(m)) >> + return ERR_CAST(m); >> + atomic_inc(&m->mnt_sb->s_active); >> + down_write(&m->mnt_sb->s_umount); >> + return dget(m->mnt_root); > > This is completely wrong. Look: > * SB_KERNMOUNT and !SB_KERNMOUNT cases are almost entirely isolated; > completely so once that ns_to_mnt becomes unconditionally non-NULL. > * in !SB_KERNMOUNT passing ns_to_mnt() is pointless - you might as > well pass existing vfsmount (or ERR_PTR()) and use _that_. fill_super() > is not used at all in that case. > * is SB_KERNMOUNT ns_to_mnt serves only as a flag, eventually > constant true. > > So let's split it in two helpers and give them sane arguments. Everything I look at with multiple helpers feels even worse to me. The above has the advantage it is the minimal change to fix the regression. So I am not worried about code correctness. I keep wondering is the intention long term to fix sget so it has an efficient data structure for finding super blocks (like an rbtree) or if the intention is to deprecate sget entirely and just have everything call alloc_super, and be responsible for their own data structures for finding existing superblocks. At this point since we are not in agreement on a proper fix I am going to plan on just queueing up a revert. So that we don't ship 4.16 with a regression in a permission check. Eric