summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2016-04-26 14:36:24 -0500
committerEric W. Biederman <ebiederm@xmission.com>2016-06-30 18:05:09 -0500
commit5f65e5ca286126a60f62c8421b77c2018a482b8a (patch)
tree6587f9ff0d9454050803e76d7347ca26bd75d73a /kernel
parent2d7f9e2ad35e4e7a3086231f19bfab33c6a8a64a (diff)
cred: Reject inodes with invalid ids in set_create_file_as()
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>
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 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);