From: Seth Forshee Date: Tue, 30 Aug 2016 04:35:01 +0000 (-0400) Subject: cred: Reject inodes with invalid ids in set_create_file_as() X-Git-Tag: firefly_0821_release~176^2~4^2~31^2~55 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4666aa74a3797d23a2344033df41b2aa0cfe5023;p=firefly-linux-kernel-4.4.55.git cred: Reject inodes with invalid ids in set_create_file_as() [ Upstream commit 5f65e5ca286126a60f62c8421b77c2018a482b8a ] 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 Signed-off-by: Eric W. Biederman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- 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);