[Devel] [PATCH RHEL7 COMMIT] ms/vfs: open() with O_CREAT should not create inodes with unknown ids
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Jul 11 18:39:42 MSK 2017
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.33.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.33.3
------>
commit af8508ce3639a3cfc54552cad18789a83bc00636
Author: Seth Forshee <seth.forshee at canonical.com>
Date: Tue Jul 11 19:39:42 2017 +0400
ms/vfs: open() with O_CREAT should not create inodes with unknown ids
may_create() rejects creation of inodes with ids which lack a
mapping into s_user_ns. However for O_CREAT may_o_create() is
is used instead. Add a similar check there.
Fixes: 036d523641c6 ("vfs: Don't create inodes with a uid or gid unknown to the vfs")
Signed-off-by: Seth Forshee <seth.forshee at canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm at xmission.com>
(cherry picked from commit 1328c727004d432bbdfba0ffa02a166df04c7305)
https://jira.sw.ru/browse/PSBM-40075
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/namei.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/namei.c b/fs/namei.c
index 42a0e6b..2b500c1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2800,10 +2800,16 @@ static inline int open_to_namei_flags(int flag)
static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode)
{
+ struct user_namespace *s_user_ns;
int error = security_path_mknod(dir, dentry, mode, 0);
if (error)
return error;
+ s_user_ns = dir->dentry->d_sb->s_user_ns;
+ if (!kuid_has_mapping(s_user_ns, current_fsuid()) ||
+ !kgid_has_mapping(s_user_ns, current_fsgid()))
+ return -EOVERFLOW;
+
error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC);
if (error)
return error;
More information about the Devel
mailing list