android_kernel_xiaomi_sm8450/fs/nfs
Jorge Mora 916ee6deae NFSv4.2: fix listxattr maximum XDR buffer size
[ Upstream commit bcac8bff90a6ee1629f90669cdb9d28fb86049b0 ]

Switch order of operations to avoid creating a short XDR buffer:
e.g., buflen = 12, old xdrlen = 12, new xdrlen = 20.

Having a short XDR buffer leads to lxa_maxcount be a few bytes
less than what is needed to retrieve the whole list when using
a buflen as returned by a call with size = 0:
    buflen = listxattr(path, NULL, 0);
    buf = malloc(buflen);
    buflen = listxattr(path, buf, buflen);

For a file with one attribute (name = '123456'), the first call
with size = 0 will return buflen = 12 ('user.123456\x00').
The second call with size = 12, sends LISTXATTRS with
lxa_maxcount = 12 + 8 (cookie) + 4 (array count) = 24. The
XDR buffer needs 8 (cookie) + 4 (array count) + 4 (name count)
+ 6 (name len) + 2 (padding) + 4 (eof) = 28 which is 4 bytes
shorter than the lxa_maxcount provided in the call.

Fixes: 04a5da690e ("NFSv4.2: define limits and sizes for user xattr handling")
Signed-off-by: Jorge Mora <mora@netapp.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:22:01 -04:00
..
blocklayout blocklayoutdriver: Fix reference leak of pnfs_device_node 2024-01-25 14:37:43 -08:00
filelayout pNFS/filelayout: Fix coalescing test for single DS 2023-01-24 07:19:55 +01:00
flexfilelayout NFS/pNFS: Report EINVAL errors from connect() to the server 2023-10-10 21:53:24 +02:00
cache_lib.c NFS client updates for Linux 4.15 2017-11-17 14:18:00 -08:00
cache_lib.h NFS client updates for Linux 4.15 2017-11-17 14:18:00 -08:00
callback_proc.c pNFS: Avoid a live lock condition in pnfs_update_layout() 2022-06-22 14:13:16 +02:00
callback_xdr.c NFS: remove unneeded check in decode_devicenotify_args() 2022-04-08 14:40:27 +02:00
callback.c SUNRPC: Cache the process user cred in the RPC server listener 2019-04-24 09:46:35 -04:00
callback.h NFSv4.1: Fix uninitialised variable in devicenotify 2022-02-16 12:54:18 +01:00
client.c NFS: Fix initialisation of nfs_client cl_flags field 2022-02-16 12:54:17 +01:00
delegation.c NFSv4: Fix a potential state reclaim deadlock 2022-11-10 18:14:16 +01:00
delegation.h NFSv4: Fix delegation return in cases where we have to retry 2021-07-20 16:05:47 +02:00
dir.c NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 21:01:04 +02:00
direct.c NFS: Use the correct commit info in nfs_join_page_group() 2023-10-10 21:53:24 +02:00
dns_resolve.c NFS: remove duplicate headers 2020-05-27 10:10:12 -04:00
dns_resolve.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export.c NFS: Add a tracepoint in nfs_fh_to_dentry() 2019-11-03 21:28:46 -05:00
file.c NFSv4: keep state manager thread active if swap is enabled 2023-03-11 16:39:38 +01:00
fs_context.c nfs: fix broken handling of the softreval mount option 2022-05-18 10:23:43 +02:00
fscache-index.c nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
fscache.c NFSv4: Fix fscache cookie aux_data to ensure change_attr is included 2020-05-08 22:20:24 +01:00
fscache.h nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
getroot.c NFS: Ensure security label is set for root inode 2020-03-30 19:56:50 -04:00
inode.c NFS: Fix up handling of outstanding layoutcommit in nfs_update_inode() 2023-03-11 16:39:38 +01:00
internal.h NFS: Memory allocation failures are not server fatal errors 2022-06-06 08:42:44 +02:00
io.c NFS: Fix up documentation warnings 2019-02-20 15:14:21 -05:00
iostat.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default 2021-03-30 14:31:49 +02:00
Makefile NFSv4.2: add client side xattr caching. 2020-07-13 17:52:46 -04:00
mount_clnt.c NFSv3: fix rpc receive buffer size for MOUNT call 2020-05-14 18:42:44 -04:00
namespace.c NFS: Fix an Oops in nfs_d_automount() 2023-01-14 10:15:34 +01:00
netns.h NFS: Add sysfs support for per-container identifier 2019-07-06 14:54:49 -04:00
nfs2super.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
nfs2xdr.c NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN 2023-09-19 12:20:15 +02:00
nfs3_fs.h NFS: Additional refactoring for fs_context conversion 2020-01-15 10:15:17 -05:00
nfs3acl.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
nfs3client.c Revert "pNFS: nfs3_set_ds_client should set NFS_CS_NOPING" 2022-08-21 15:15:18 +02:00
nfs3proc.c nfs: fix acl memory leak of posix_acl_create() 2021-07-20 16:05:51 +02:00
nfs3super.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
nfs3xdr.c NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN 2023-09-19 12:20:15 +02:00
nfs4_fs.h NFSv4: keep state manager thread active if swap is enabled 2023-03-11 16:39:38 +01:00
nfs4client.c nfs4: Fix kmemleak when allocate slot failed 2022-11-10 18:14:16 +01:00
nfs4file.c NFSv4.2 fix problems with __nfs42_ssc_open 2022-08-31 17:15:15 +02:00
nfs4getroot.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfs4idmap.c NFSv4: Fix races in the legacy idmapper upcall 2022-08-25 11:37:54 +02:00
nfs4idmap.h NFS: Move nfs_idmap.h into fs/nfs/ 2015-04-23 15:16:14 -04:00
nfs4namespace.c NFSv4 handle port presence in fs_location server string 2022-02-16 12:54:18 +01:00
nfs4proc.c NFSv4.2: fix nfs4_listxattr kernel BUG at mm/usercopy.c:102 2024-03-26 18:22:01 -04:00
nfs4renewd.c NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals 2020-02-04 12:27:55 -05:00
nfs4session.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
nfs4session.h NFSv4.1: Bump the default callback session slot count to 16 2019-03-02 16:25:26 -05:00
nfs4state.c NFSv4: Fix a nfs4_state_manager() race 2023-10-10 21:53:38 +02:00
nfs4super.c NFS: Adjust fs_context error logging 2021-01-19 18:27:30 +01:00
nfs4sysctl.c nfs: Do not convert nfs_idmap_cache_timeout to jiffies 2018-01-18 15:10:47 -05:00
nfs4trace.c pNFS/flexfiles: Add tracing for layout errors 2020-01-15 10:54:33 -05:00
nfs4trace.h nfs4trace: fix state manager flag printing 2023-03-11 16:39:38 +01:00
nfs4xdr.c NFSv4.2: Fix a memory stomp in decode_attr_security_label 2023-01-14 10:15:33 +01:00
nfs42.h NFSv4.2: fix listxattr maximum XDR buffer size 2024-03-26 18:22:01 -04:00
nfs42proc.c NFSv4.2: fix handling of COPY ERR_OFFLOAD_NO_REQ 2023-09-19 12:20:16 +02:00
nfs42xattr.c NFSv4.2: fix failure to unregister shrinker 2020-11-12 10:40:02 -05:00
nfs42xdr.c NFSv42: Don't fail clone() unless the OP_CLONE operation failed 2021-12-01 09:19:03 +01:00
nfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfsroot.c nfsroot: Default mount option should ask for built-in NFS version 2020-11-02 10:29:03 -05:00
nfstrace.c NFS: Add trace events to report non-zero NFS status codes 2019-02-13 12:03:21 -05:00
nfstrace.h nfs: define and use the NFS_INO_INVALID_XATTR flag 2020-07-13 17:52:45 -04:00
pagelist.c NFS: Avoid writeback threads getting stuck in mempool_alloc() 2022-04-13 21:01:03 +02:00
pnfs_dev.c NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info 2023-09-19 12:20:25 +02:00
pnfs_nfs.c NFS: nfsiod should not block forever in mempool_alloc() 2022-04-13 21:01:03 +02:00
pnfs.c pNFS: Fix a hang in nfs4_evict_inode() 2023-10-25 11:54:24 +02:00
pnfs.h pNFS: Avoid a live lock condition in pnfs_update_layout() 2022-06-22 14:13:16 +02:00
proc.c NFS: Add softreval behaviour to nfs_lookup_revalidate() 2020-01-24 16:51:13 -05:00
read.c NFS: Trace short NFS READs 2020-06-11 13:33:48 -04:00
super.c NFSv4: Turn off open-by-filehandle and NFS re-export for NFSv4.0 2022-09-23 14:16:57 +02:00
symlink.c nfs: pass the correct prototype to read_cache_page 2019-05-09 16:26:57 -04:00
sysctl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sysfs.c NFS: rename nfs_client_kset to nfs_kset 2023-10-10 21:53:36 +02:00
sysfs.h NFSv4: Fix up RCU annotations for struct nfs_netns_client 2020-10-15 13:31:08 -04:00
unlink.c NFS: Avoid referencing the cred twice in async rename/unlink 2020-03-16 08:34:29 -04:00
write.c NFS: Use the correct commit info in nfs_join_page_group() 2023-10-10 21:53:24 +02:00