Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: chuck.lever@oracle.com
Cc: linux-nfs@vger.kernel.org, dai.ngo@oracle.com, aglo@umich.edu
Subject: [PATCH 1/2] nfsd: zero out pointers after putting nfsd_files on COPY setup error
Date: Tue, 17 Jan 2023 14:38:30 -0500	[thread overview]
Message-ID: <20230117193831.75201-2-jlayton@kernel.org> (raw)
In-Reply-To: <20230117193831.75201-1-jlayton@kernel.org>

At first, I thought this might be a source of nfsd_file overputs, but
the current callers seem to avoid an extra put when nfsd4_verify_copy
returns an error.

Still, it's "bad form" to leave the pointers filled out when we don't
have a reference to them anymore, and that might lead to bugs later.
Zero them out as a defensive coding measure.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/nfs4proc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index dbaf33398c82..37a9cc8ae7ae 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1214,8 +1214,10 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	return status;
 out_put_dst:
 	nfsd_file_put(*dst);
+	*dst = NULL;
 out_put_src:
 	nfsd_file_put(*src);
+	*src = NULL;
 	goto out;
 }
 
-- 
2.39.0


  reply	other threads:[~2023-01-17 21:18 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 19:38 [PATCH 0/2] nfsd: COPY refcounting fix and cleanup Jeff Layton
2023-01-17 19:38 ` Jeff Layton [this message]
2023-01-17 19:38 ` [PATCH 2/2] nfsd: clean up potential nfsd_file refcount leaks in COPY codepath Jeff Layton
2023-01-18 14:42   ` Olga Kornievskaia
2023-01-18 15:27     ` Jeff Layton
2023-01-18 16:29       ` Olga Kornievskaia
2023-01-18 16:39         ` Chuck Lever III
2023-01-18 17:06           ` Jeff Layton
2023-01-18 17:11             ` Chuck Lever III
2023-01-18 17:26               ` Jeff Layton
2023-01-18 17:48                 ` Olga Kornievskaia
2023-01-18 16:57         ` Jeff Layton
2023-01-18 17:07           ` Olga Kornievskaia
2023-01-18 18:16             ` Olga Kornievskaia
2023-01-18 18:34               ` Jeff Layton
2023-01-19  1:45                 ` Olga Kornievskaia
2023-01-19  5:05   ` dai.ngo
2023-01-19 10:56     ` Jeff Layton
2023-01-19 18:38       ` dai.ngo
2023-01-20 11:43         ` Jeff Layton
2023-01-21 18:56           ` dai.ngo
2023-01-21 19:50             ` dai.ngo
2023-01-21 20:05               ` Jeff Layton
2023-01-21 20:12                 ` Chuck Lever III
2023-01-21 21:28                   ` dai.ngo
2023-01-22 16:45                     ` Chuck Lever III
2023-01-22 17:10                       ` Chuck Lever III
2023-01-23 12:17                         ` Jeff Layton
2023-01-23 15:22                       ` Olga Kornievskaia
2023-01-23 15:32                         ` Jeff Layton
2023-01-23 20:32                       ` dai.ngo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230117193831.75201-2-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=aglo@umich.edu \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox