From patchwork Wed Dec 2 15:40:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 7748581 Return-Path: X-Original-To: patchwork-selinux@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 140B1BEEE1 for ; Wed, 2 Dec 2015 16:31:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 692A620549 for ; Wed, 2 Dec 2015 16:31:10 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 975D020503 for ; Wed, 2 Dec 2015 16:31:09 +0000 (UTC) X-TM-IMSS-Message-ID: <237ba8b70000694f@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id 237ba8b70000694f ; Wed, 2 Dec 2015 11:31:26 -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 tB2GTURc011368; Wed, 2 Dec 2015 11:29:32 -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 tB2FgWb8185592 for ; Wed, 2 Dec 2015 10:42: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 tB2FgWlF006648 for ; Wed, 2 Dec 2015 10:42:32 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1ChAAA0EF9Wm6rfVdFeGQEBAQEPAQEBAYRMu3CEFoYOAoIYAQEBAQEBEgEBAQEBBgsLCSGEYwEBAQMSFRkBATcBD1E0AQUBHAYBEiKIDaEVgTE+MYpXhVQBBYwjAQEBAQEFAgEaBgqEOoIQiSWFEY4giEGWTIYhi2s2gReCZw0WB4F1UwGEJIFKAQEB X-IPAS-Result: A1ChAAA0EF9Wm6rfVdFeGQEBAQEPAQEBAYRMu3CEFoYOAoIYAQEBAQEBEgEBAQEBBgsLCSGEYwEBAQMSFRkBATcBD1E0AQUBHAYBEiKIDaEVgTE+MYpXhVQBBYwjAQEBAQEFAgEaBgqEOoIQiSWFEY4giEGWTIYhi2s2gReCZw0WB4F1UwGEJIFKAQEB X-IronPort-AV: E=Sophos;i="5.20,373,1444708800"; d="scan'208";a="4986126" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 02 Dec 2015 10:42:30 -0500 X-TM-IMSS-Message-ID: <2356c43200015ef2@nsa.gov> Received: from mail-io0-f170.google.com (mail-io0-f170.google.com [209.85.223.170]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 2356c43200015ef2 ; Wed, 2 Dec 2015 10:42:38 -0500 Received: by iouu10 with SMTP id u10so50610340iou.0 for ; Wed, 02 Dec 2015 07:42:28 -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=bkRe5U2UpQgULK5Azn5m9AdiB/mL14V0IVwDQ0BPzXo=; b=kx6MOETx239Wa5oD5AgqVL/AHDLslDPs4PH5HisuiINUiTErlzsVtwd8RnRG+3f5Da TFgpffq+lV17omUPO5YESSxLy0v+V/4/LOh6qkEiDQg+NcJJaGv8i8iBERHzoBbgG5+g n+gzy51Fuj1mhgB+8oHhqVArrXphE2G3lRXYARzx1pvE7iQnhycGWpPWMX4q36mZBd7e wPzZP83JNi/Du0h6wEczOMfX4Aa9JXB6yKvLxFl3jGpKMHbU9s5h2MrItwQ73Pd+CI34 XWG33I9PSVGb3ifuRUhpLPT1BUSYX3ovxNvsZaVlABBtk1ALLmIJpqnrxcXVUdV6Z3Z/ DMPA== 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=bkRe5U2UpQgULK5Azn5m9AdiB/mL14V0IVwDQ0BPzXo=; b=YQXf8N/DmIVBbCS41PN6sm4nZJ9s8JUXVAUkWE9ykC1AH4/HUdmmWr9KrFRwZzof5g Pc2gSvbVEQFZpeLKGOcuh/P97eqDQuzNebjbAUqHLLXw9NaGgGb4RrFdqwe4DcTvEbs8 53tEQtcBSIDjixFe8fiS8wuV+87CRejcKiVuOVOoqzSBrc8u55t/QHASWefIR+cQ0GH5 MSAJatVSa97Cu+rBilFAWtqdPuxBo7jetgbJ23PBt4R3FmhHuzgfpf3vBhlDtOPibgcV XKT3Qv8vwOShq9KlbPcNe5FaoTMCWnCCDhC5ZGnd5KCMnLXYDSOkD1Geg1aYv0lAWcun GFaQ== X-Gm-Message-State: ALoCoQnE0mEdKNbITTPKnJMo6AZf7A0ddkyoAdRnI8D71cuUG5UqDXMsXI2+NQ3Qr3T/6jTDAaFk X-Received: by 10.107.16.144 with SMTP id 16mr4984200ioq.119.1449070948719; Wed, 02 Dec 2015 07:42:28 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id 90sm1356405ioq.29.2015.12.02.07.42.28 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Dec 2015 07:42:28 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" , Alexander Viro Subject: [PATCH 12/19] fs: Don't remove suid for CAP_FSETID in s_user_ns Date: Wed, 2 Dec 2015 09:40:12 -0600 Message-Id: <1449070821-73820-13-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449070821-73820-1-git-send-email-seth.forshee@canonical.com> References: <1449070821-73820-1-git-send-email-seth.forshee@canonical.com> X-TM-AS-MML: disable X-Mailman-Approved-At: Wed, 02 Dec 2015 11:15:49 -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;