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 55e19a01e152894b6dce5cc7f5d6d0db607c1314
Author: Seth Forshee <[email protected]>
Date:   Tue Jul 11 19:39:37 2017 +0400

    ms/fs: Refuse uid/gid changes which don't map into s_user_ns
    
    Add checks to notify_change to verify that uid and gid changes
    will map into the superblock's user namespace. If they do not
    fail with -EOVERFLOW.
    
    This is mandatory so that fileystems don't have to even think
    of dealing with ia_uid and ia_gid that
    
    --EWB Moved the test from inode_change_ok to notify_change
    
    Signed-off-by: Seth Forshee <[email protected]>
    Acked-by: Serge Hallyn <[email protected]>
    Signed-off-by: Eric W. Biederman <[email protected]>
    (cherry picked from commit a475acf01f79e89a1a5845733e10108d80f77188)
    
    https://jira.sw.ru/browse/PSBM-40075
    
    Signed-off-by: Konstantin Khorenko <[email protected]>
---
 fs/attr.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/attr.c b/fs/attr.c
index 7262f3b..00dc159 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -260,6 +260,17 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
        if (!(attr->ia_valid & ~(ATTR_KILL_SUID | ATTR_KILL_SGID)))
                return 0;
 
+       /*
+        * Verify that uid/gid changes are valid in the target
+        * namespace of the superblock.
+        */
+       if (ia_valid & ATTR_UID &&
+           !kuid_has_mapping(inode->i_sb->s_user_ns, attr->ia_uid))
+               return -EOVERFLOW;
+       if (ia_valid & ATTR_GID &&
+           !kgid_has_mapping(inode->i_sb->s_user_ns, attr->ia_gid))
+               return -EOVERFLOW;
+
        error = security_inode_setattr(dentry, attr);
        if (error)
                return error;
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to