From patchwork Fri Apr 22 15:38:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 613739 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qs0FV3hvCz9t4h for ; Sat, 23 Apr 2016 01:40:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=XGzaWnpz; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdBb-0002d8-OT; Fri, 22 Apr 2016 15:40:03 +0000 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atdB8-0001jb-AT for linux-mtd@lists.infradead.org; Fri, 22 Apr 2016 15:39:35 +0000 Received: by mail-oi0-x22a.google.com with SMTP id p188so136862941oih.2 for ; Fri, 22 Apr 2016 08:39:17 -0700 (PDT) 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=0m4ffYALMihro6bdklmIe2XMfJSlAnRWQ33d61k9VBs=; b=XGzaWnpz9XTKp+S/HxsnArXw/nLxWb+HvF5BBf1WHRoY7tFSYeAKD5IRSzSEYItaK1 LaKuV8SwtBn31Td2mxb2HajN44tzJEANEbruJLxYsehKMkirCUBg9Akvq6V+DSGthL5J FGVwXckTF1hMHW86i4BjRakr6xvpf9Zw8pRjPPJ4lRq3ykxrd+ULeQSLnPslTVhEvfoe 4y9cSe1ucW96hREF0SnBpUCSU3OqLCHLSTywsBiBNbTcqhalSTXwbuA5mGXsndjlReei FrJPR7kda4faq38zt/pn4PSEi2CrYtH6b8ixK3DBQcR9FKQ+T60fh/Dlu3QxYypSmRRF 5BVQ== 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=0m4ffYALMihro6bdklmIe2XMfJSlAnRWQ33d61k9VBs=; b=F6k1HuI8z/M7nBbQwtv7uJO5PNP4YUgWyvL3ToMZ7HbDJ1Ujl1Xj26fixfe2Iw2X1r YItxmNkyo13KlCTibuVGZk/gJz5G2iGafu/aEMbFthNOJJn3wSJ+uTpQdGrb0+Iqb1EH 8bdhwE9dLsh05PoFfc60EhYv5Obojh8kPHAYvOazjmEsWOkFAfZd7NFjj/KuSdZiO4m1 L+uwPveNaQXPKTMA6hKR5/uNO3rjFXTq5wkc26hVOJh+Nx4zhcsWXm2Yzjyy51zpzo1u 6XbfW0hU8o5u9EBUTSpv0Zvdpo4+7ur/rwhz9VNVPqxam+b7jW8c35JoPoTZ2CKhgFtV H2Kw== X-Gm-Message-State: AOPr4FWjyG3hi/zsQDFpeGEovaYgERmpe8TTa5nMQnF3zyaECOGWIwo4Z3Xu5kZx5YYOFopJ X-Received: by 10.202.224.70 with SMTP id x67mr9173568oig.124.1461339557039; Fri, 22 Apr 2016 08:39:17 -0700 (PDT) Received: from localhost ([2605:a601:aab:f920:ad1c:41df:dcb1:a4a0]) by smtp.gmail.com with ESMTPSA id e189sm2060939oig.10.2016.04.22.08.39.16 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 22 Apr 2016 08:39:16 -0700 (PDT) From: Seth Forshee To: "Eric W. Biederman" Subject: [PATCH v3 11/21] cred: Reject inodes with invalid ids in set_create_file_as() Date: Fri, 22 Apr 2016 10:38:28 -0500 Message-Id: <1461339521-123191-12-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> References: <1461339521-123191-1-git-send-email-seth.forshee@canonical.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160422_083934_564258_757A9711 X-CRM114-Status: UNSURE ( 8.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4003:c06:0:0:0:22a listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-bcache@vger.kernel.org, Serge Hallyn , Seth Forshee , dm-devel@redhat.com, Miklos Szeredi , Richard Weinberger , linux-security-module@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, cgroups@vger.kernel.org, Pavel Tikhomirov MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 0c0cd8a62285..5f264fb5737d 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);