diff mbox series

nfsd: ensure that nfsd4_fattr_args.context is zeroed out

Message ID 20240822-nfsd-fixes-v1-1-905ae5249531@kernel.org (mailing list archive)
State New
Headers show
Series nfsd: ensure that nfsd4_fattr_args.context is zeroed out | expand

Commit Message

Jeff Layton Aug. 22, 2024, 6:47 p.m. UTC
If nfsd4_encode_fattr4 ends up doing a "goto out" before we get to
checking for the security label, then args.context will be set to
uninitialized junk on the stack, which we'll then try to free.
Initialize it early.

Fixes: f59388a579c6 ("NFSD: Add nfsd4_encode_fattr4_sec_label()")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/nfs4xdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


---
base-commit: afec13278f4ed7dad696cfdaddbee978d905b9f2
change-id: 20240822-nfsd-fixes-0c7bf42b0331

Best regards,

Comments

Chuck Lever III Aug. 22, 2024, 6:54 p.m. UTC | #1
On Thu, 22 Aug 2024 14:47:01 -0400, Jeff Layton wrote:
> If nfsd4_encode_fattr4 ends up doing a "goto out" before we get to
> checking for the security label, then args.context will be set to
> uninitialized junk on the stack, which we'll then try to free.
> Initialize it early.
> 
> 

Applied to nfsd-fixes for v6.11-rc, thanks!

[1/1] nfsd: ensure that nfsd4_fattr_args.context is zeroed out
      commit: f58bab6fd4063913bd8321e99874b8239e9ba726
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 643ca3f8ebb3..ee1c6a68b663 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3537,6 +3537,9 @@  nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 	args.dentry = dentry;
 	args.ignore_crossmnt = (ignore_crossmnt != 0);
 	args.acl = NULL;
+#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
+	args.context = NULL;
+#endif
 
 	/*
 	 * Make a local copy of the attribute bitmap that can be modified.
@@ -3609,7 +3612,6 @@  nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 	args.contextsupport = false;
 
 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
-	args.context = NULL;
 	if ((attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) ||
 	     attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
 		if (exp->ex_flags & NFSEXP_SECURITY_LABEL)