NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error.
Dai Ngo authored
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: default avatarDai Ngo <dai.ngo@oracle.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
bc2b500d
Name Last commit Last update
..
blocklayout pnfs/blocklayout: off by one in bl_map_stripe()
filelayout NFS: fix an incorrect limit in filelayout_decode_layout()
flexfilelayout pNFS/flexfiles: fix incorrect size check in decode_nfs_fh()
Kconfig nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license
cache_lib.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
cache_lib.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
callback.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
callback.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
callback_proc.c NFSv4/pnfs: Return valid stateids in nfs_layout_find_inode_by_stateid()
callback_xdr.c NFSv4.0 fix client reference leak in callback
client.c NFS: Fix a potential NULL dereference in nfs_get_client()
delegation.c NFS: Fix a soft lockup in the delegation recovery code
delegation.h NFS: Fix a soft lockup in the delegation recovery code
dir.c nfs: Fix security label length not being reset
direct.c SUNRPC reverting d03727b2 ("NFSv4 fix CLOSE not waiting for direct IO compeletion")
dns_resolve.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
dns_resolve.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
export.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
file.c SUNRPC reverting d03727b2 ("NFSv4 fix CLOSE not waiting for direct IO compeletion")
fscache-index.c fscache: remove unused ->now_uncached callback
fscache.c nfs: define nfs_inc_fscache_stats and using it as possible
fscache.h NFS: Use i_writecount to control whether to get an fscache cookie in nfs_open()
getroot.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally
inode.c NFS: Deal correctly with attribute generation counter overflow
internal.h
io.c
iostat.h
mount_clnt.c
namespace.c
netns.h
nfs.h
nfs2super.c
nfs2xdr.c
nfs3_fs.h
nfs3acl.c
nfs3client.c
nfs3proc.c
nfs3super.c
nfs3xdr.c
nfs42.h
nfs42proc.c
nfs42xdr.c
nfs4_fs.h
nfs4client.c
nfs4file.c
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c
nfs4renewd.c
nfs4session.c
nfs4session.h
nfs4state.c
nfs4super.c
nfs4sysctl.c
nfs4trace.c
nfs4trace.h
nfs4xdr.c
nfsroot.c
nfstrace.c
nfstrace.h
pagelist.c
pnfs.c
pnfs.h
pnfs_dev.c
pnfs_nfs.c
proc.c
read.c
super.c
symlink.c
sysctl.c
unlink.c
write.c