From patchwork Wed Jul 15 19:46:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 6800341 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3EBAFC05AC for ; Wed, 15 Jul 2015 19:48:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61CC02057E for ; Wed, 15 Jul 2015 19:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79FAD20574 for ; Wed, 15 Jul 2015 19:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753731AbbGOTra (ORCPT ); Wed, 15 Jul 2015 15:47:30 -0400 Received: from mail-ob0-f180.google.com ([209.85.214.180]:33631 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753719AbbGOTrY (ORCPT ); Wed, 15 Jul 2015 15:47:24 -0400 Received: by obbgp5 with SMTP id gp5so33480973obb.0 for ; Wed, 15 Jul 2015 12:47:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZiliDaAoPDi90/TYv2c2D4HUyZHpQsfeYRpR7VcX3Kk=; b=J1ZDYS7m2TRf+PrIhqk796CdZF2rmsJrEPHAr4bGaRXXlRHMMyi6+H9zyXS7+zpavc JuQnorCejdssoaYon10Nb5qvPSxvssS21ba1St+Jzds766xwIRO1euUMIjmiArbV5Fa5 GU7hmj5qu0H+DsdgOFPwCfiMxfmKbvq3RNQx5iqi6OPq7natPzJJTFkWELaBAUnR6vAp 9lsJNJYfpm9elJgYb4jKHiik6VS5heobF26mINlNeKir1zSO/8B1bBQjuNCd75jNWFL5 zij2BmcIbjQJ3KisqM1iwXFltXLXZSpa2xsTdb1VquTfnpCcU1mOP70xFoLKsCZbKYYW 7r3A== X-Gm-Message-State: ALoCoQm24y9DxltXXIwYjiw/3S9IXkOX4cj+RExmvTdiVTdB4ILaoU8DS963jkS8XS93u4ko4P82 X-Received: by 10.182.18.72 with SMTP id u8mr5190645obd.8.1436989644277; Wed, 15 Jul 2015 12:47:24 -0700 (PDT) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id sm8sm2913603obb.13.2015.07.15.12.47.23 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 15 Jul 2015 12:47:23 -0700 (PDT) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro , Casey Schaufler Cc: Serge Hallyn , Andy Lutomirski , Seth Forshee , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, linux-kernel@vger.kernel.org, James Morris , "Serge E. Hallyn" Subject: [PATCH 7/7] smack: Don't use security labels for user namespace mounts Date: Wed, 15 Jul 2015 14:46:08 -0500 Message-Id: <1436989569-69582-8-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436989569-69582-1-git-send-email-seth.forshee@canonical.com> References: <1436989569-69582-1-git-send-email-seth.forshee@canonical.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid use of untrusted security labels when s_user_ns != init_user_ns: - smk_fetch: refuse to read labels from disk - smack_inode_init_security: return -ENOTSUPP - smack_d_instantiate: don't use security xattrs from disk Signed-off-by: Seth Forshee --- security/smack/smack_lsm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index a143328f75eb..6a849da94f47 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -255,6 +255,9 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip, char *buffer; struct smack_known *skp = NULL; + if (ip->i_sb->s_user_ns != &init_user_ns) + return NULL; + if (ip->i_op->getxattr == NULL) return ERR_PTR(-EOPNOTSUPP); @@ -833,6 +836,9 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir, struct smack_known *dsp = smk_of_inode(dir); int may; + if (inode->i_sb->s_user_ns != &init_user_ns) + return -ENOTSUPP; + if (name) *name = XATTR_SMACK_SUFFIX; @@ -3176,11 +3182,13 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) } /* * No xattr support means, alas, no SMACK label. - * Use the aforeapplied default. + * Use the aforeapplied default. Also don't use + * xattrs from userns mounts. * It would be curious if the label of the task * does not match that assigned. */ - if (inode->i_op->getxattr == NULL) + if (inode->i_sb->s_user_ns != &init_user_ns || + inode->i_op->getxattr == NULL) break; /* * Get the dentry for xattr.