]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
NFS: avoid NULL dereference in nfs_destroy_server
authorNeilBrown <neilb@suse.de>
Thu, 13 Dec 2012 04:14:36 +0000 (15:14 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Jan 2013 17:06:54 +0000 (09:06 -0800)
commit f259613a1e4b44a0cf85a5dafd931be96ee7c9e5 upstream.

In rare circumstances, nfs_clone_server() of a v2 or v3 server can get
an error between setting server->destory (to nfs_destroy_server), and
calling nfs_start_lockd (which will set server->nlm_host).

If this happens, nfs_clone_server will call nfs_free_server which
will call nfs_destroy_server and thence nlmclnt_done(NULL).  This
causes the NULL to be dereferenced.

So add a guard to only call nlmclnt_done() if ->nlm_host is not NULL.

The other guards there are irrelevant as nlm_host can only be non-NULL
if one of these flags are set - so remove those tests.  (Thanks to Trond
for this suggestion).

This is suitable for any stable kernel since 2.6.25.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/client.c

index 60f7e4ec842cf1d4fd48f21862d1d5ece26efc88..37f6de36973c638bc547d2302e9b8acd511069fe 100644 (file)
@@ -694,8 +694,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
  */
 static void nfs_destroy_server(struct nfs_server *server)
 {
-       if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
-                       !(server->flags & NFS_MOUNT_LOCAL_FCNTL))
+       if (server->nlm_host)
                nlmclnt_done(server->nlm_host);
 }