Skip to content
  • Vivek Goyal's avatar
    f1aa1774
    virtiofsd: Switch creds, drop FSETID for system.posix_acl_access xattr · f1aa1774
    Vivek Goyal authored
    
    
    When posix access acls are set on a file, it can lead to adjusting file
    permissions (mode) as well. If caller does not have CAP_FSETID and it
    also does not have membership of owner group, this will lead to clearing
    SGID bit in mode.
    
    Current fuse code is written in such a way that it expects file server
    to take care of chaning file mode (permission), if there is a need.
    Right now, host kernel does not clear SGID bit because virtiofsd is
    running as root and has CAP_FSETID. For host kernel to clear SGID,
    virtiofsd need to switch to gid of caller in guest and also drop
    CAP_FSETID (if caller did not have it to begin with).
    
    If SGID needs to be cleared, client will set the flag
    FUSE_SETXATTR_ACL_KILL_SGID in setxattr request. In that case server
    should kill sgid.
    
    Currently just switch to uid/gid of the caller and drop CAP_FSETID
    and that should do it.
    
    This should fix the xfstest generic/375 test case.
    
    We don't have to switch uid for this to work. That could be one optimization
    that pass a parameter to lo_change_cred() to only switch gid and not uid.
    
    Also this will not work whenever (if ever) we support idmapped mounts. In
    that case it is possible that uid/gid in request are 0/0 but still we
    need to clear SGID. So we will have to pick a non-root sgid and switch
    to that instead. That's an TODO item for future when idmapped mount
    support is introduced.
    
    This patch only adds the capability to switch creds and drop FSETID
    when acl xattr is set. This does not take affect yet. It can take
    affect when next patch adds the capability to enable posix_acl.
    
    Reported-by: default avatarLuis Henriques <lhenriques@suse.de>
    Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
    Message-Id: <20210622150852.1507204-7-vgoyal@redhat.com>
    Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    f1aa1774
    virtiofsd: Switch creds, drop FSETID for system.posix_acl_access xattr
    Vivek Goyal authored
    
    
    When posix access acls are set on a file, it can lead to adjusting file
    permissions (mode) as well. If caller does not have CAP_FSETID and it
    also does not have membership of owner group, this will lead to clearing
    SGID bit in mode.
    
    Current fuse code is written in such a way that it expects file server
    to take care of chaning file mode (permission), if there is a need.
    Right now, host kernel does not clear SGID bit because virtiofsd is
    running as root and has CAP_FSETID. For host kernel to clear SGID,
    virtiofsd need to switch to gid of caller in guest and also drop
    CAP_FSETID (if caller did not have it to begin with).
    
    If SGID needs to be cleared, client will set the flag
    FUSE_SETXATTR_ACL_KILL_SGID in setxattr request. In that case server
    should kill sgid.
    
    Currently just switch to uid/gid of the caller and drop CAP_FSETID
    and that should do it.
    
    This should fix the xfstest generic/375 test case.
    
    We don't have to switch uid for this to work. That could be one optimization
    that pass a parameter to lo_change_cred() to only switch gid and not uid.
    
    Also this will not work whenever (if ever) we support idmapped mounts. In
    that case it is possible that uid/gid in request are 0/0 but still we
    need to clear SGID. So we will have to pick a non-root sgid and switch
    to that instead. That's an TODO item for future when idmapped mount
    support is introduced.
    
    This patch only adds the capability to switch creds and drop FSETID
    when acl xattr is set. This does not take affect yet. It can take
    affect when next patch adds the capability to enable posix_acl.
    
    Reported-by: default avatarLuis Henriques <lhenriques@suse.de>
    Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
    Message-Id: <20210622150852.1507204-7-vgoyal@redhat.com>
    Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
Loading