From 278ca0e5896f54134c36f71acefb77a9b61bb5ae Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 22 Aug 2024 14:47:01 -0400 Subject: [PATCH] nfsd: ensure that nfsd4_fattr_args.context is zeroed out BugLink: https://bugs.launchpad.net/bugs/2084225 [ Upstream commit f58bab6fd4063913bd8321e99874b8239e9ba726 ] 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 Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin [koichiroden: Adjusted context based on Ubuntu Sauce patches] Signed-off-by: Koichiro Den Signed-off-by: Stefan Bader --- fs/nfsd/nfs4xdr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a01f31714d9d..a67416ada5da 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3512,6 +3512,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.context = NULL; +#endif /* * Make a local copy of the attribute bitmap that can be modified.