nfsd: return NFS4ERR_NOTSUPP for unsupported netloc4 types

nfsd4_decode_nl4_server() handled only NL4_NETADDR and returned
nfserr_bad_xdr for NL4_NAME and NL4_URL. Those forms are well-formed XDR,
so BADXDR is misleading -- the request is unsupported, not malformed.

Decode and discard the utf8str_cis for NL4_NAME and NL4_URL to keep the
stream consistent, and return nfserr_notsupp. nfsd4_proc_compound() honors
a decode-time op->status, so the op fails without executing.

Fixes: 84e1b21d5e ("NFSD add ca_source_server<> to COPY")
Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260710-nfsd-testing-v3-7-a0ff7db6aa3e@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
Jeff Layton 2026-07-10 10:00:11 -04:00 committed by Chuck Lever
parent 3b0c3595db
commit 45b06a7508

View File

@ -2123,6 +2123,7 @@ static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp,
{
struct nfs42_netaddr *naddr;
__be32 *p;
u32 str_len;
if (xdr_stream_decode_u32(argp->xdr, &ns->nl4_type) < 0)
return nfserr_bad_xdr;
@ -2152,6 +2153,18 @@ static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp,
return nfserr_bad_xdr;
memcpy(naddr->addr, p, naddr->addr_len);
break;
case NL4_NAME:
case NL4_URL:
/*
* Well-formed XDR, but only NL4_NETADDR is supported. Consume
* the utf8str_cis to keep the stream aligned, then return
* NFS4ERR_NOTSUPP rather than the misleading NFS4ERR_BADXDR.
*/
if (xdr_stream_decode_u32(argp->xdr, &str_len) < 0)
return nfserr_bad_xdr;
if (!xdr_inline_decode(argp->xdr, str_len))
return nfserr_bad_xdr;
return nfserr_notsupp;
default:
return nfserr_bad_xdr;
}