Skip to content

Commit

Permalink
cred: Reject inodes with invalid ids in set_create_file_as()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Signed-off-by: Eric W. Biederman <[email protected]>
  • Loading branch information
Seth Forshee authored and ebiederm committed Jun 30, 2016
1 parent 2d7f9e2 commit 5f65e5c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5f65e5c

Please sign in to comment.