cred: Reject inodes with invalid ids in set_create_file_as()
authorSeth Forshee <seth.forshee@canonical.com>
Tue, 26 Apr 2016 19:36:24 +0000 (14:36 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 30 Jun 2016 23:05:09 +0000 (18:05 -0500)
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>
kernel/cred.c

index 0c0cd8a62285279a521b3f724189fe997da84ddb..5f264fb5737dcd01329fdeff02a4143584ba9c38 100644 (file)
@@ -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);