]> git.hungrycats.org Git - linux/commitdiff
nfsd: return correct lockowner when there is a race on hash insert
authorJ. Bruce Fields <bfields@redhat.com>
Mon, 23 Mar 2015 15:02:30 +0000 (11:02 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Apr 2015 08:10:16 +0000 (10:10 +0200)
commit 340f0ba1c6c8412aa35fd6476044836b84361ea6 upstream.

alloc_init_lock_stateowner can return an already freed entry if there is
a race to put openowners in the hashtable.

Noticed by inspection after Jeff Layton fixed the same bug for open
owners.  Depending on client behavior, this one may be trickier to
trigger in practice.

Fixes: c58c6610ec24 "nfsd: Protect adding/removing lock owners using client_lock"
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Acked-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfsd/nfs4state.c

index 6488fd5d0437d013db227dcb26b61b9f0aea8948..7cfb905a1e90d26f3a72f3699dfecdb92a55c492 100644 (file)
@@ -5065,7 +5065,7 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp,
        } else
                nfs4_free_lockowner(&lo->lo_owner);
        spin_unlock(&clp->cl_lock);
-       return lo;
+       return ret;
 }
 
 static void