nfsd: make calculate reserved space correctly
Subsystems (2)
PATCH 1/1 nfsd: make calculate reserved space correctly
rpcsec_gss_oid is defined as below, So, must using XDR_LEN to calculate reserved space. When len is not the multiples of 4, client will get bad data.
struct rpcsec_gss_oid {
unsigned int len;
u8 data[GSS_OID_MAX_LEN];
};--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -3233,7 +3233,7 @@ nfsd4_do_encode_secinfo(struct nfsd4_compoundres *resp,if (rpcauth_get_gssinfo (pf, &info) ==0 ) { supported++; -RESERVE_SPACE (4 +4 + info.oid.len +4 +4 ); +RESERVE_SPACE (4 +4 +XDR_LEN (info.oid.len) +4 +4 );WRITE32 (RPC_AUTH_GSS );WRITE32 (info.oid.len);WRITEMEM (info.oid.data, info.oid.len);
Signature · 1 line
1.8.4.2
Quoted 2 lines · Kinglong Mee
rpcsec_gss_oidis defined as below, So, must usingXDR_LENto calculate reserved space. When len is not the multiples of 4, client will get bad data.
Looking at the definition of RESERVE_SPACE: first, it doesn't actually advance any pointers, all it does is an overflow check, so there shouldn't be data corruption unless we're at the end of a page (which shouldn't happen here). Second, RESERVE_SPACE actually rounds up for is, so we wouldn't hit that problem anyway.
Nevertheless, agreed that it's probably good practice to round up here as well.
--b.
Quoted 26 lines
struct rpcsec_gss_oid { unsigned int len; u8 data[GSS_OID_MAX_LEN]; };Signed-off-by Kinglong Mee <[email protected]>--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/nfsd/nfs4xdr.c +1
-1@@ -3233,7 +3233,7 @@ nfsd4_do_encode_secinfo(struct nfsd4_compoundres *resp,if (rpcauth_get_gssinfo (pf, &info) ==0 ) { supported++; -RESERVE_SPACE (4 +4 + info.oid.len +4 +4 ); +RESERVE_SPACE (4 +4 +XDR_LEN (info.oid.len) +4 +4 );WRITE32 (RPC_AUTH_GSS );WRITE32 (info.oid.len);WRITEMEM (info.oid.data, info.oid.len);Signature · 1 line
1.8.4.2
Quoted 9 lines · J. Bruce Fields
Quoted 2 lines · Kinglong Mee
rpcsec_gss_oidis defined as below, So, must usingXDR_LENto calculate reserved space. When len is not the multiples of 4, client will get bad data.Looking at the definition of
RESERVE_SPACE: first, it doesn't actually advance any pointers, all it does is an overflow check, so there shouldn't be data corruption unless we're at the end of a page (which shouldn't happen here). Second,RESERVE_SPACEactually rounds up for is, so we wouldn't hit that problem anyway.
Yes.
Quoted 3 lines
Nevertheless, agreed that it's probably good practice to round up here as well.
Thank you.
thanks,
Kinglong Mee
Quoted 30 lines
--b.
Quoted 26 lines
struct rpcsec_gss_oid { unsigned int len; u8 data[GSS_OID_MAX_LEN]; };Signed-off-by Kinglong Mee <[email protected]>--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/nfsd/nfs4xdr.c +1
-1@@ -3233,7 +3233,7 @@ nfsd4_do_encode_secinfo(struct nfsd4_compoundres *resp,if (rpcauth_get_gssinfo (pf, &info) ==0 ) { supported++; -RESERVE_SPACE (4 +4 + info.oid.len +4 +4 ); +RESERVE_SPACE (4 +4 +XDR_LEN (info.oid.len) +4 +4 );WRITE32 (RPC_AUTH_GSS );WRITE32 (info.oid.len);WRITEMEM (info.oid.data, info.oid.len);Signature · 1 line
1.8.4.2