From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ig0-x22a.google.com ([2607:f8b0:4001:c05::22a]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aG9Uy-00011I-AL for linux-mtd@lists.infradead.org; Mon, 04 Jan 2016 18:04:52 +0000 Received: by mail-ig0-x22a.google.com with SMTP id ik10so188520igb.1 for ; Mon, 04 Jan 2016 10:04:25 -0800 (PST) From: Seth Forshee To: "Eric W. Biederman" Cc: Alexander Viro , Serge Hallyn , Richard Weinberger , Austin S Hemmelgarn , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, fuse-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Seth Forshee Subject: [PATCH RESEND v2 08/18] cred: Reject inodes with invalid ids in set_create_file_as() Date: Mon, 4 Jan 2016 12:03:47 -0600 Message-Id: <1451930639-94331-9-git-send-email-seth.forshee@canonical.com> In-Reply-To: <1451930639-94331-1-git-send-email-seth.forshee@canonical.com> References: <1451930639-94331-1-git-send-email-seth.forshee@canonical.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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); -- 1.9.1