summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2016-08-30 00:35:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-15 08:27:49 +0200
commit4666aa74a3797d23a2344033df41b2aa0cfe5023 (patch)
treea2fe19be357d9b8caab67933a7e3162814876b2c /kernel
parent6a90aa44065afb34ad4f37676b734c0e3eeafe6a (diff)
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 <seth.forshee@canonical.com> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cred.c2
1 files changed, 2 insertions, 0 deletions
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);