Received: by 10.223.185.116 with SMTP id b49csp93544wrg; Thu, 8 Mar 2018 13:29:52 -0800 (PST) X-Google-Smtp-Source: AG47ELsEDzxgPghpnYgWeCY/e0ZaPj4SuixjckForWsc5Fny0zb/GzqJc+r2iODKOn6s+cnQiflV X-Received: by 10.99.119.203 with SMTP id s194mr17348885pgc.26.1520544592393; Thu, 08 Mar 2018 13:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520544592; cv=none; d=google.com; s=arc-20160816; b=IGteiUMSWr5Mjmd0ZV7tsTbw1zm0GCQgqa+4N+Rls6+/SZRgSzZx/8Kr1vCDG+b4mM BOkKpF+u6BYVrIYq91ubZd9iJ3cuif96WarNYN/R7Dy669nYQvGlGfDGXElKvkEXpTJ8 A96qS5i0OlbN2fdQgnVKSX2AYs9L7HoCKw+oltxOx+y8BwlgU97+RPFap/VkXaj9a/X9 YbNYZtOazQ5cdRi3kABNRYOiWwKPHfH4BY4FrnPMaN0tjo4IiwluaNaqcDgzdOsHlPfK qYFXcmZIMDxM0dAUMmbWrXr3KJ3CRM/EEJm2gClUV0XR2ej2HMzM3Avnj3d1JyWkwU/a +qzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=f6G6Ea8n9kRE9nqEugi52Bv4qJmhd8Rsh3hW5UJuPTk=; b=M1gLU2lehPcY7YN/BeRKEQSKbZ1O6hN0Zd5YRMyXyWRKt0rKzVFMoi+eCRZ+Fc8y6B D3C/1yIN9JjWNQRuTJT8/5/nHMEE6D4fYqgazzTIYICjf1Lx8I4IDooA2TjrBeonOBjQ g+slSPVuEQck51P4ZO1DCoJThRZCteOIYrUf++3CKfr2oo30cFnaGO3Ok8dp220NKRP4 DPYykUfq/tNgQtx595Q/sFXDl4SLv/g64OsaUoPBPehaVOn9caxlLdmznlM96y9fnpaQ s/aFSwlBMlX3ijsXr1C3iGK3l9f6uN5gE5nzLPww76da7OiC9T24BBMthRGxthP2D6t/ gYzg== 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 o5si16412246pfh.390.2018.03.08.13.29.37; Thu, 08 Mar 2018 13:29:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145AbeCHV2p (ORCPT + 99 others); Thu, 8 Mar 2018 16:28:45 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:49506 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbeCHV2n (ORCPT ); Thu, 8 Mar 2018 16:28:43 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1eu35e-0005wS-Bv; Thu, 08 Mar 2018 14:28:42 -0700 Received: from 174-19-85-160.omah.qwest.net ([174.19.85.160] helo=x220.int.ebiederm.org) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1eu35d-00018P-D9; Thu, 08 Mar 2018 14:28:42 -0700 From: "Eric W. Biederman" To: Miklos Szeredi Cc: linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, Alban Crequy , Seth Forshee , Sargun Dhillon , Dongsu Park , "Serge E. Hallyn" , "Eric W. Biederman" Date: Thu, 8 Mar 2018 15:24:30 -0600 Message-Id: <20180308212430.7053-4-ebiederm@xmission.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <87ina6ntx0.fsf_-_@xmission.com> References: <87ina6ntx0.fsf_-_@xmission.com> X-XM-SPF: eid=1eu35d-00018P-D9;;;mid=<20180308212430.7053-4-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=174.19.85.160;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19FKH3DUmGxielOaRTG2ESlhZMEzvRxDqI= X-SA-Exim-Connect-IP: 174.19.85.160 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa02.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, T_TooManySym_02,XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 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.5001] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=278] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=278 X-Spam-Combo: ;Miklos Szeredi X-Spam-Relay-Country: X-Spam-Timing: total 596 ms - load_scoreonly_sql: 0.22 (0.0%), signal_user_changed: 4.7 (0.8%), b_tie_ro: 2.8 (0.5%), parse: 1.88 (0.3%), extract_message_metadata: 45 (7.6%), get_uri_detail_list: 4.2 (0.7%), tests_pri_-1000: 24 (4.0%), tests_pri_-950: 2.5 (0.4%), tests_pri_-900: 1.79 (0.3%), tests_pri_-400: 33 (5.5%), check_bayes: 31 (5.2%), b_tokenize: 13 (2.2%), b_tok_get_all: 8 (1.3%), b_comp_prob: 3.8 (0.6%), b_tok_touch_all: 2.8 (0.5%), b_finish: 0.87 (0.1%), tests_pri_0: 463 (77.7%), check_dkim_signature: 1.20 (0.2%), check_dkim_adsp: 5 (0.9%), tests_pri_500: 11 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v9 4/4] fuse: Restrict allow_other to the superblock's namespace or a descendant 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 in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Seth Forshee Unprivileged users are normally restricted from mounting with the allow_other option by system policy, but this could be bypassed for a mount done with user namespace root permissions. In such cases allow_other should not allow users outside the userns to access the mount as doing so would give the unprivileged user the ability to manipulate processes it would otherwise be unable to manipulate. Restrict allow_other to apply to users in the same userns used at mount or a descendant of that namespace. Also export current_in_userns() for use by fuse when built as a module. Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: "Eric W. Biederman" Cc: Serge Hallyn Cc: Miklos Szeredi Acked-by: Miklos Szeredi Reviewed-by: Serge Hallyn Reviewed-by: "Eric W. Biederman" Signed-off-by: Seth Forshee Signed-off-by: Dongsu Park Signed-off-by: Eric W. Biederman --- fs/fuse/dir.c | 2 +- kernel/user_namespace.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index ad1cfac1942f..d41559a0aa6b 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1030,7 +1030,7 @@ int fuse_allow_current_process(struct fuse_conn *fc) const struct cred *cred; if (fc->allow_other) - return 1; + return current_in_userns(fc->user_ns); cred = current_cred(); if (uid_eq(cred->euid, fc->user_id) && diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 246d4d4ce5c7..492c255e6c5a 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -1235,6 +1235,7 @@ bool current_in_userns(const struct user_namespace *target_ns) { return in_userns(target_ns, current_user_ns()); } +EXPORT_SYMBOL(current_in_userns); static inline struct user_namespace *to_user_ns(struct ns_common *ns) { -- 2.14.1