mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: "J. Bruce Fields" <bfields@fieldses.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Vasily Averin <vvs@virtuozzo.com>,
	"open list:KERNEL NFSD, SUNRPC,
	AND LOCKD SERVERS"  <linux-nfs@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: usama.anjum@collabora.com, kernel@collabora.com,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] nfs: check nf pointer for validity before use
Date: Tue, 21 Dec 2021 23:55:35 +0500	[thread overview]
Message-ID: <YcIjJ4jN3ax1rqaE@debian-BULLSEYE-live-builder-AMD64> (raw)

Pointer nf can be NULL. It should be validated before dereferencing it.

Fixes: 8628027ba8 ("nfs: block notification on fs with its own ->lock")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 fs/nfsd/nfs4state.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a526d4183348..bdd30988e615 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -6947,6 +6947,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		goto out;
 	}
 
+	if (!nf) {
+		status = nfserr_openmode;
+		goto out;
+	}
+
 	/*
 	 * Most filesystems with their own ->lock operations will block
 	 * the nfsd thread waiting to acquire the lock.  That leads to
@@ -6957,11 +6962,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	if (nf->nf_file->f_op->lock)
 		fl_flags &= ~FL_SLEEP;
 
-	if (!nf) {
-		status = nfserr_openmode;
-		goto out;
-	}
-
 	nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn);
 	if (!nbl) {
 		dprintk("NFSD: %s: unable to allocate block!\n", __func__);
-- 
2.30.2


             reply	other threads:[~2021-12-21 18:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 18:55 Muhammad Usama Anjum [this message]
2021-12-21 20:00 ` Chuck Lever III
2021-12-21 22:18 ` Konstantin Ryabitsev
2021-12-22  6:06   ` Tomeu Vizoso

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=YcIjJ4jN3ax1rqaE@debian-BULLSEYE-live-builder-AMD64 \
    --to=usama.anjum@collabora.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=vvs@virtuozzo.com \
    /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

all inboxes | Powered by JetHome®