From patchwork Mon Dec 7 21:21:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 7792581 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 ECF7EBEEE1 for ; Mon, 7 Dec 2015 22:45:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E92B200F0 for ; Mon, 7 Dec 2015 22:45:58 +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 7912D2056E for ; Mon, 7 Dec 2015 22:45:57 +0000 (UTC) X-TM-IMSS-Message-ID: <3e9824c700029522@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 3e9824c700029522 ; Mon, 7 Dec 2015 17:43:47 -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 tB7MhgiB008867; Mon, 7 Dec 2015 17:43:45 -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 tB7LQXNK263196 for ; Mon, 7 Dec 2015 16:26:33 -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 tB7LNOqD001405 for ; Mon, 7 Dec 2015 16:26:33 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CeBABD9WVW/7HVVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGEyKIDaJHgTE+MYpXhVQBBYt1AQEBAQYCARoGCoQ6ghCOOI4kiEKWTYYhi242gRdjggSCH1MBhW4BAQE X-IPAS-Result: A1CeBABD9WVW/7HVVdFeGQEBAQEPAQEBAYRLuxeEFoYOAoITAQEBAQEBhUABAQEDEhUZAQE3AQ9RNAEFARwGEyKIDaJHgTE+MYpXhVQBBYt1AQEBAQYCARoGCoQ6ghCOOI4kiEKWTYYhi242gRdjggSCH1MBhW4BAQE X-IronPort-AV: E=Sophos;i="5.20,396,1444708800"; d="scan'208";a="5004903" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 07 Dec 2015 16:23:31 -0500 X-TM-IMSS-Message-ID: <3e4e9c550002801f@nsa.gov> Received: from mail-ig0-f177.google.com (mail-ig0-f177.google.com [209.85.213.177]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 3e4e9c550002801f ; Mon, 7 Dec 2015 16:23:28 -0500 Received: by igcto18 with SMTP id to18so2837374igc.0 for ; Mon, 07 Dec 2015 13:23:30 -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=lNMozmbm7pfdxKvWpPZNWPjG7CuFlV9btFcGtcgM/0U=; b=mHWoYYkYi8E/gTj3/iVQzowzcdMfB1fEd00ULkOIxlgHkzM9AwXIegAykPIJRX0KVp YhTkMInAG0FaVXuXe9adjNlKfhqyrgGsWWYuGgbM6/NqUsnzok7dUTtOGOYav328NE4g ytRFcfIxa8H7qVbZWuky3r9odMYz1mlLV8VuOju6+6zkukqDJWILXh7oi2RKXzKiKfRF TM6qrhTT2yuEaHLMMArxuXGUMExVreNs/gV+w2t8CFJtLKGko7LPMZtYGQvGUflre0U1 ycL/0Iz7wIKH3nM7Qy1lTaITkL9ISemn2NTVLEHwUBy2CRtmrpF7T7EDTqLhIL8di77E I2Pw== 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=lNMozmbm7pfdxKvWpPZNWPjG7CuFlV9btFcGtcgM/0U=; b=d02qjgRuetmV6LTjyEzIJMKZbEWiz9Ry1lIqgtHXILsgUV2yPH7wC+a4djiCs4rNhX a36L7sE4rC0lwV0AKeWK8uyCBkF39CiXy2SYwjIidI22DCtByBZmH3p3tM+F7moG1Wl1 AGex13i9qD2oCozmH6FB7+FKXlAGIwjoV/7iQu5RHCHgJqUQSuUpUH7XMDic86Ht3qob aZVqjeY1s/IObTh/W9UaqxS077xVVSvSnik7lSkFhIMA22gQN2rsI0saIrEh4VQ88QOt LIZHtcCuHJPRJ5uH/4W1O5acEeV5EdJRbpofoM5moObcn1SWDexQ12TUuLGN0yj6BR6r 8BSA== X-Gm-Message-State: ALoCoQllb/RuSqMYiW0QA7Vna8GGZzcXapNZ9XW95fbPP8RMvs/M4cLac26SH4CGkydFc9N3ncjuLr9NJ0x9mWSIhFNe39JFGA== X-Received: by 10.50.155.33 with SMTP id vt1mr499391igb.64.1449523410071; Mon, 07 Dec 2015 13:23:30 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by smtp.gmail.com with ESMTPSA id l21sm214732ioe.21.2015.12.07.13.23.29 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 07 Dec 2015 13:23:29 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" Subject: [PATCH v2 08/18] cred: Reject inodes with invalid ids in set_create_file_as() Date: Mon, 7 Dec 2015 15:21:17 -0600 Message-Id: <1449523289-144238-9-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, Alexander Viro , 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 Using INVALID_[UG]ID for the LSM file creation context doesn't make sense, so return an error if the inode passed to set_create_file_as() has an invalid id. Signed-off-by: Seth Forshee Acked-by: Serge Hallyn --- kernel/cred.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/cred.c b/kernel/cred.c index 71179a09c1d6..ff8606f77d90 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -689,6 +689,8 @@ EXPORT_SYMBOL(set_security_override_from_ctx); */ int set_create_files_as(struct cred *new, struct inode *inode) { + if (!uid_valid(inode->i_uid) || !gid_valid(inode->i_gid)) + return -EINVAL; new->fsuid = inode->i_uid; new->fsgid = inode->i_gid; return security_kernel_create_files_as(new, inode);