public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-nfs@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 15/15] nfsd: zero out pointers after putting nfsd_files on COPY setup error
Date: Sun, 26 Feb 2023 21:10:34 -0500	[thread overview]
Message-ID: <20230227021038.1052958-15-sashal@kernel.org> (raw)
In-Reply-To: <20230227021038.1052958-1-sashal@kernel.org>

From: Jeff Layton <jlayton@kernel.org>

[ Upstream commit 1f0001d43d0c0ac2a19a34a914f6595ad97cbc1d ]

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>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@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 452ed633a2c76..bd7846758947b 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1059,8 +1059,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


      parent reply	other threads:[~2023-02-27  2:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27  2:10 [PATCH AUTOSEL 5.4 01/15] drm/amd/display: Fix potential null-deref in dm_resume Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 02/15] drm/omap: dsi: Fix excessive stack usage Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 03/15] HID: Add Mapping for System Microphone Mute Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 04/15] drm/radeon: free iio for atombios when driver shutdown Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 05/15] drm/msm/dsi: Add missing check for alloc_ordered_workqueue Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 06/15] docs/scripts/gdb: add necessary make scripts_gdb step Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 07/15] ASoC: kirkwood: Iterate over array indexes instead of using pointer math Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 08/15] regulator: max77802: Bounds check regulator id against opmode Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 09/15] regulator: s5m8767: Bounds check id indexing into arrays Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 10/15] hwmon: (coretemp) Simplify platform device handling Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 11/15] pinctrl: at91: use devm_kasprintf() to avoid potential leaks Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 12/15] drm: panel-orientation-quirks: Add quirk for Lenovo IdeaPad Duet 3 10IGL5 Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 13/15] dm thin: add cond_resched() to various workqueue loops Sasha Levin
2023-02-27  2:10 ` [PATCH AUTOSEL 5.4 14/15] dm cache: " Sasha Levin
2023-02-27  2:10 ` Sasha Levin [this message]

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=20230227021038.1052958-15-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=stable@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