linux-stable/fs/nfsd
Chuck Lever efcae97fa4 NFSD: da_addr_body field missing in some GETDEVICEINFO replies
[ Upstream commit 6372e2ee62 ]

The XDR specification in RFC 8881 looks like this:

struct device_addr4 {
	layouttype4	da_layout_type;
	opaque		da_addr_body<>;
};

struct GETDEVICEINFO4resok {
	device_addr4	gdir_device_addr;
	bitmap4		gdir_notification;
};

union GETDEVICEINFO4res switch (nfsstat4 gdir_status) {
case NFS4_OK:
	GETDEVICEINFO4resok gdir_resok4;
case NFS4ERR_TOOSMALL:
	count4		gdir_mincount;
default:
	void;
};

Looking at nfsd4_encode_getdeviceinfo() ....

When the client provides a zero gd_maxcount, then the Linux NFS
server implementation encodes the da_layout_type field and then
skips the da_addr_body field completely, proceeding directly to
encode gdir_notification field.

There does not appear to be an option in the specification to skip
encoding da_addr_body. Moreover, Section 18.40.3 says:

> If the client wants to just update or turn off notifications, it
> MAY send a GETDEVICEINFO operation with gdia_maxcount set to zero.
> In that event, if the device ID is valid, the reply's da_addr_body
> field of the gdir_device_addr field will be of zero length.

Since the layout drivers are responsible for encoding the
da_addr_body field, put this fix inside the ->encode_getdeviceinfo
methods.

Fixes: 9cf514ccfa ("nfsd: implement pNFS operations")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Tom Haynes <loghyr@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:48:24 +02:00
..
Kconfig
Makefile
acl.h
auth.c
auth.h
blocklayout.c nfsd: call op_release, even when op_func returns an error 2023-03-31 17:29:49 -04:00
blocklayoutxdr.c NFSD: da_addr_body field missing in some GETDEVICEINFO replies 2023-09-13 09:48:24 +02:00
blocklayoutxdr.h
cache.h nfsd: move init of percpu reply_cache_stats counters back to nfsd_init_net 2023-07-19 16:36:51 +02:00
current_stateid.h
export.c NFSD: Handle new xprtsec= export option 2023-04-27 18:49:24 -04:00
export.h NFSD: Handle new xprtsec= export option 2023-04-27 18:49:24 -04:00
filecache.c NFSD: Fix problem of COMMIT and NFS4ERR_DELAY in infinite loop 2023-04-27 18:49:24 -04:00
filecache.h NFSD: Convert filecache to rhltable 2023-04-26 09:04:59 -04:00
flexfilelayout.c
flexfilelayoutxdr.c NFSD: da_addr_body field missing in some GETDEVICEINFO replies 2023-09-13 09:48:24 +02:00
flexfilelayoutxdr.h
idmap.h
lockd.c
netns.h
nfs2acl.c
nfs3acl.c
nfs3proc.c
nfs3xdr.c
nfs4acl.c
nfs4callback.c NFSD: callback request does not use correct credential for AUTH_SYS 2023-04-04 09:55:27 -04:00
nfs4idmap.c SUNRPC: return proper error from get_expiry() 2023-04-26 09:05:00 -04:00
nfs4layouts.c
nfs4proc.c
nfs4recover.c
nfs4state.c nfsd: Fix race to FREE_STATEID and cl_revoked 2023-08-30 14:52:40 +02:00
nfs4xdr.c NFSD: da_addr_body field missing in some GETDEVICEINFO replies 2023-09-13 09:48:24 +02:00
nfscache.c nfsd: move init of percpu reply_cache_stats counters back to nfsd_init_net 2023-07-19 16:36:51 +02:00
nfsctl.c nfsd: move init of percpu reply_cache_stats counters back to nfsd_init_net 2023-07-19 16:36:51 +02:00
nfsd.h
nfsfh.c
nfsfh.h
nfsproc.c
nfssvc.c
nfsxdr.c
pnfs.h
state.h
stats.c
stats.h
trace.c
trace.h NFSD: Remove open coding of string copy 2023-05-15 08:03:04 -04:00
vfs.c nfsd: use vfs setgid helper 2023-07-19 16:36:54 +02:00
vfs.h
xdr.h
xdr3.h
xdr4.h
xdr4cb.h