linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Benjamin Coddington" <bcodding@redhat.com>
To: anna.schumaker@netapp.com
Cc: linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, trond.myklebust@hammerspace.com,
	"Roberto Bergantinos Corpas" <rbergant@redhat.com>,
	syzbot <syzbot+228a82b263b5da91883d@syzkaller.appspotmail.com>
Subject: Re: WARNING: locking bug in nfs_get_client
Date: Thu, 09 May 2019 07:37:50 -0400	[thread overview]
Message-ID: <FE8462BD-2B07-4AC1-A739-E3D429DDA134@redhat.com> (raw)
In-Reply-To: <C6C33F7F-8CD2-4E0F-82BA-5443133FBB54@redhat.com>

I think nfs_get_client and nfs_match_client could use a refactor.. but 
the
trivial fix is:

8<---------------------------------

 From 4ef2fc5912c5980890e781f8c0d941330254c100 Mon Sep 17 00:00:00 2001
Message-Id: 
<4ef2fc5912c5980890e781f8c0d941330254c100.1557401467.git.bcodding@redhat.com>
 From: Benjamin Coddington <bcodding@redhat.com>
Date: Thu, 9 May 2019 07:25:21 -0400
Subject: [PATCH] NFS: Fix a double unlock from nfs_match,get_client

Now that nfs_match_client drops the nfs_client_lock, we should be 
careful
to always return it in the same condition: locked.

Fixes: 950a578c6128 ("NFS: make nfs_match_client killable")
Reported-by: syzbot+228a82b263b5da91883d@syzkaller.appspotmail.com
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
  fs/nfs/client.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 06e8719655f0..da74c4c4a244 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -299,9 +299,9 @@ static struct nfs_client *nfs_match_client(const 
struct nfs_client_initdata *dat
  			spin_unlock(&nn->nfs_client_lock);
  			error = nfs_wait_client_init_complete(clp);
  			nfs_put_client(clp);
+			spin_lock(&nn->nfs_client_lock);
  			if (error < 0)
  				return ERR_PTR(error);
-			spin_lock(&nn->nfs_client_lock);
  			goto again;
  		}

-- 
2.20.1

  reply	other threads:[~2019-05-09 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  0:17 WARNING: locking bug in nfs_get_client syzbot
2019-05-09  2:46 ` syzbot
2019-05-09 10:55 ` Benjamin Coddington
2019-05-09 11:37   ` Benjamin Coddington [this message]
2019-05-09 12:06     ` Schumaker, Anna

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=FE8462BD-2B07-4AC1-A739-E3D429DDA134@redhat.com \
    --to=bcodding@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=rbergant@redhat.com \
    --cc=syzbot+228a82b263b5da91883d@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=trond.myklebust@hammerspace.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;
as well as URLs for NNTP newsgroup(s).