Commit 1328c727 authored by Seth Forshee's avatar Seth Forshee Committed by Eric W. Biederman

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: 036d5236 ("vfs: Don't create inodes with a uid or gid unknown to the vfs")
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 68eb94f1
...@@ -2941,10 +2941,16 @@ static inline int open_to_namei_flags(int flag) ...@@ -2941,10 +2941,16 @@ static inline int open_to_namei_flags(int flag)
static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode) static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode)
{ {
struct user_namespace *s_user_ns;
int error = security_path_mknod(dir, dentry, mode, 0); int error = security_path_mknod(dir, dentry, mode, 0);
if (error) if (error)
return 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); error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC);
if (error) if (error)
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment