From patchwork Mon Dec 7 21:21:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 7792801 Return-Path: X-Original-To: patchwork-selinux@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 3A1D79F1C2 for ; Mon, 7 Dec 2015 23:06:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CCF82057F for ; Mon, 7 Dec 2015 23:06:12 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (emvm-gh1-uea08.nsa.gov [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DCB2202DD for ; Mon, 7 Dec 2015 23:06:11 +0000 (UTC) X-TM-IMSS-Message-ID: <3eab17ec000298c4@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1) id 3eab17ec000298c4 ; Mon, 7 Dec 2015 18:04:29 -0500 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB7N4Fp8010593; Mon, 7 Dec 2015 18:04:17 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id tB7LQWiu263192 for ; Mon, 7 Dec 2015 16:26:32 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB7LNOq9001405 for ; Mon, 7 Dec 2015 16:26:32 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CeBABD9WVW/7PfVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2iR4ExPjGKV4VUAQWLdQEBAQEBBQIBGgYKhDqCEIklhROOJIhClk2GIYtuNoEXY4IEDR2BdVMBhCSBSgEBAQ X-IPAS-Result: A1CeBABD9WVW/7PfVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGARIiiA2iR4ExPjGKV4VUAQWLdQEBAQEBBQIBGgYKhDqCEIklhROOJIhClk2GIYtuNoEXY4IEDR2BdVMBhCSBSgEBAQ X-IronPort-AV: E=Sophos;i="5.20,396,1444708800"; d="scan'208";a="5004908" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 07 Dec 2015 16:23:37 -0500 X-TM-IMSS-Message-ID: <3e4eb40a00028028@nsa.gov> Received: from mail-io0-f179.google.com (mail-io0-f179.google.com [209.85.223.179]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 3e4eb40a00028028 ; Mon, 7 Dec 2015 16:23:34 -0500 Received: by iouu10 with SMTP id u10so4193844iou.0 for ; Mon, 07 Dec 2015 13:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DCvnLT65nycMpsxA09TDRCyuGx9zvoBgy7rP6HVW8qA=; b=YsuuaSsx28wpBKckuTTSOaM8pNKp5iZufrKDy04Fcb0bPTrM5r71fSGZCkon9ge8sH GcKxTTOipWRNE0d+dk4hDM+yYupopGv4SpVXYLF3PxTY2f5rBTMaODPvCYdGzzQNyV0h /Xoyx92fTv66eC7CkCoAUT33GOvEy7Juu3jOGIRMLhwfonLL0vTCXYaZaLeCs5kPTmHY OdFATCwAIKswra+AqvxRSc7KlyVWQ/mT7f+WTErqgJ04TZ+vOUUYNsOfd3VoyHGJKvhG AvVdl6E969NtZ/nscQdmXTLXyytD8UXMBR8WmvgwlMjl1QqhPKmPuuhazpeGATYNl4Yz 4DLg== 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=DCvnLT65nycMpsxA09TDRCyuGx9zvoBgy7rP6HVW8qA=; b=mB3s9yWt8Tscs9XqGq/1zLbkxOgFpiQOTzefrXMVQl9Hhs8hU7u1mh8peLgZx4dppO LmeYUg+Tdqlt7MybQQS6Th8kt3UTgS0GggJEuXW8rXN01q+P27NS+baH/g049eDODGHS +/x5/uH5fi67uo6j9zmGpebveeOIdZ+sbd5rlTF0M3/MMd4JWsNionwvDEb2dsbMCrnh 3Tcs23MrlK1wK/S0/J6Yi0JoP/NRrm3gCMmltSIJnjquvXnZ11TDrnA5Epsc+X3qgqjf zAXlXGQjUkdg2o4x/XM/RWBwGX7grks+bvEfua8GFmGrmvWsGvvFvRLvzfuPH7yzwbQf 47QQ== X-Gm-Message-State: ALoCoQm0z3JflNvv7PJXx+44Un4I5h/Qd23YUcUa/Yi0C6OCZQjBuOQ+tLMfzcO+jycregIr1I48rI8/e6SwauHGa7WbPB1/iw== X-Received: by 10.107.39.193 with SMTP id n184mr552538ion.14.1449523416111; Mon, 07 Dec 2015 13:23:36 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id qb7sm218636igb.8.2015.12.07.13.23.35 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 07 Dec 2015 13:23:35 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH v2 12/18] fs: Don't remove suid for CAP_FSETID in s_user_ns Date: Mon, 7 Dec 2015 15:21:21 -0600 Message-Id: <1449523289-144238-13-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449523289-144238-1-git-send-email-seth.forshee@canonical.com> References: <1449523289-144238-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Mon, 07 Dec 2015 16:44:28 -0500 X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: Serge Hallyn , Seth Forshee , dm-devel@redhat.com, Miklos Szeredi , Richard Weinberger , linux-security-module@vger.kernel.org, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, fuse-devel@lists.sourceforge.net, Austin S Hemmelgarn , linux-mtd@lists.infradead.org, selinux@tycho.nsa.gov, linux-fsdevel@vger.kernel.org MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 Expand the check in should_remove_suid() to keep privileges for CAP_FSETID in s_user_ns rather than init_user_ns. Signed-off-by: Seth Forshee Acked-by: Serge Hallyn --- fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 01c036fe1950..3e7c74da9304 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1684,7 +1684,8 @@ int should_remove_suid(struct dentry *dentry) if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) kill |= ATTR_KILL_SGID; - if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode))) + if (unlikely(kill && !ns_capable(dentry->d_sb->s_user_ns, CAP_FSETID) && + S_ISREG(mode))) return kill; return 0;