• D
    NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. · 420a6301
    Dai Ngo 提交于
    stable inclusion
    from stable-v5.10.44
    commit 6e13b9bc66f0e34238aa7b9486a0575177fb7955
    bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=414
    CVE: NA
    
    -------------------------------------------------
    
    commit f8849e20 upstream.
    
    Currently if __nfs4_proc_set_acl fails with NFS4ERR_BADOWNER it
    re-enables the idmapper by clearing NFS_CAP_UIDGID_NOMAP before
    retrying again. The NFS_CAP_UIDGID_NOMAP remains cleared even if
    the retry fails. This causes problem for subsequent setattr
    requests for v4 server that does not have idmapping configured.
    
    This patch modifies nfs4_proc_set_acl to detect NFS4ERR_BADOWNER
    and NFS4ERR_BADNAME and skips the retry, since the kernel isn't
    involved in encoding the ACEs, and return -EINVAL.
    
    Steps to reproduce the problem:
    
     # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt
     # touch /tmp/mnt/file1
     # chown 99 /tmp/mnt/file1
     # nfs4_setfacl -a A::unknown.user@xyz.com:wrtncy /tmp/mnt/file1
     Failed setxattr operation: Invalid argument
     # chown 99 /tmp/mnt/file1
     chown: changing ownership of ‘/tmp/mnt/file1’: Invalid argument
     # umount /tmp/mnt
     # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt
     # chown 99 /tmp/mnt/file1
     #
    
    v2: detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skip retry
           in nfs4_proc_set_acl.
    Signed-off-by: NDai Ngo <dai.ngo@oracle.com>
    Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Nwangyongpan <1071630525@qq.com>
    Reviewed-by: Jian Cheng <cj.chengjian(a)huawei.com>
    420a6301
nfs4proc.c 278.6 KB