Skip to content

Commit 5f65e5c

Browse files
Seth Forsheeebiederm
authored andcommitted
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 <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 2d7f9e2 commit 5f65e5c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/cred.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ EXPORT_SYMBOL(set_security_override_from_ctx);
689689
*/
690690
int set_create_files_as(struct cred *new, struct inode *inode)
691691
{
692+
if (!uid_valid(inode->i_uid) || !gid_valid(inode->i_gid))
693+
return -EINVAL;
692694
new->fsuid = inode->i_uid;
693695
new->fsgid = inode->i_gid;
694696
return security_kernel_create_files_as(new, inode);

0 commit comments

Comments
 (0)