Skip to contentSkip to conversation

NFSD: change LISTXATTRS cookie encoding to big-endian

PATCH In review Jorge Mora 2 participants 2 messages Jan 25, 2024

Subsystems (2)
lore
Share & tools
lore

Jorge Mora

author
#0 lore raw

PATCH 1/1 NFSD: change LISTXATTRS cookie encoding to big-endian

Function nfsd4_listxattr_validate_cookie() expects the cookie as an offset to the list thus it needs to be encoded in big-endian.

Fixes 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
---
 fs/nfsd/nfs4xdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +3 -1
index 26993bf368fc..913d566519bf 100644
@@ -5142,6 +5142,7 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 	u64 cookie;
 	char *sp;
 	__be32 status, tmp;
+	__be64 wire_cookie;
 	__be32 *p;
 	u32 nuser;
 
@@ -5235,7 +5236,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 
 	cookie = offset + count;
 
-	write_bytes_to_xdr_buf(xdr->buf, cookie_offset, &cookie, 8);
+	wire_cookie = cpu_to_be64(cookie);
+	write_bytes_to_xdr_buf(xdr->buf, cookie_offset, &wire_cookie, 8);
 	tmp = cpu_to_be32(count);
 	write_bytes_to_xdr_buf(xdr->buf, count_offset, &tmp, 4);
 out:
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Jorge Mora

Function nfsd4_listxattr_validate_cookie() expects the cookie as an offset to the list thus it needs to be encoded in big-endian.

Fixes 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
---
 fs/nfsd/nfs4xdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -0
index 26993bf368fc..913d566519bf 100644
@@ -5142,6 +5142,7 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 	u64 cookie;
 	char *sp;
 	__be32 status, tmp;
+	__be64 wire_cookie;
 	__be32 *p;
 	u32 nuser;
 

fs/nfsd/nfs4xdr.c nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr, · line 5243

Quoted 9 lines
fs/nfsd/nfs4xdr.c +2 -1
@@ -5235,7 +5236,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 
 	cookie = offset + count;
 
-	write_bytes_to_xdr_buf(xdr->buf, cookie_offset, &cookie, 8);
+	wire_cookie = cpu_to_be64(cookie);
+	write_bytes_to_xdr_buf(xdr->buf, cookie_offset, &wire_cookie, 8);
 	tmp = cpu_to_be32(count);
 	write_bytes_to_xdr_buf(xdr->buf, count_offset, &tmp, 4);
 out: