mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nfsd: ensure that nfsd4_fattr_args.context is zeroed out
@ 2024-08-22 18:47 Jeff Layton
  2024-08-22 18:54 ` Chuck Lever
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2024-08-22 18:47 UTC (permalink / raw)
  To: Chuck Lever, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey
  Cc: linux-nfs, linux-kernel, Jeff Layton

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(-)

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)

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

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfsd: ensure that nfsd4_fattr_args.context is zeroed out
  2024-08-22 18:47 [PATCH] nfsd: ensure that nfsd4_fattr_args.context is zeroed out Jeff Layton
@ 2024-08-22 18:54 ` Chuck Lever
  0 siblings, 0 replies; 2+ messages in thread
From: Chuck Lever @ 2024-08-22 18:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
	linux-kernel

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

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-22 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22 18:47 [PATCH] nfsd: ensure that nfsd4_fattr_args.context is zeroed out Jeff Layton
2024-08-22 18:54 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®