[Devel] [PATCH RH7 15/22] port/cred: Reject inodes with invalid ids in set_create_file_as()
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Mar 10 08:32:08 PST 2016
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 at canonical.com>
Acked-by: Serge Hallyn <serge.hallyn at canonical.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
kernel/cred.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/cred.c b/kernel/cred.c
index 9eb3bae..3d30da3 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -682,6 +682,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);
--
1.9.3
More information about the Devel
mailing list