]> www.infradead.org Git - users/hch/xfs.git/commitdiff
nfsd: ensure that nfsd4_fattr_args.context is zeroed out
authorJeff Layton <jlayton@kernel.org>
Thu, 22 Aug 2024 18:47:01 +0000 (14:47 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 22 Aug 2024 18:49:10 +0000 (14:49 -0400)
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>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4xdr.c

index 42b41d55d4edf81abbb54b3e6ac6aade33f8b935..43ccf6119cf128e8e62ccd75c4e68a2736fd907d 100644 (file)
@@ -3545,6 +3545,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.
@@ -3617,7 +3620,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)