From patchwork Wed Jul 30 12:27:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4647961 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FAF79F32F for ; Wed, 30 Jul 2014 12:28:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4CCE200E9 for ; Wed, 30 Jul 2014 12:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E615F2015E for ; Wed, 30 Jul 2014 12:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754676AbaG3M15 (ORCPT ); Wed, 30 Jul 2014 08:27:57 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:39603 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754671AbaG3M1z (ORCPT ); Wed, 30 Jul 2014 08:27:55 -0400 Received: by mail-qa0-f46.google.com with SMTP id v10so1182695qac.19 for ; Wed, 30 Jul 2014 05:27:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PQqVYAg6HgDhclH7Ql1wM4ImgMjVUzoHCk0kYK+aP4o=; b=iR951YLlq4zOXHWYwQdzUip5jrIqqIDx4kziMPGjtY6BbJ3MOdQqaBlHeZibKhgbqs c4uzaz1KuAv8gyOVrGUaitAXBQmSWjhS3xyRecJ6t+DdGCgmIaA9vpUjRvTWN14xgk4p LGzOjliTlkTLeGLxAXFX+aWR2fi6JwpyjWIeu+ljg5UjAXypd+APyO1yb3Tky+ClmsbT xjVVSjh+zEA7KEDxaDI1493AShYTCrLgr3fMy42Z7SEJjlLoqlc1y4Up88S3PN613bhR c7IiqGp1FU3bSXJulRJsifNrOAfKhIFzE6MfTkk5GdWb4WW7SmkDg5u1dep/+N/lKU7F QKYw== X-Gm-Message-State: ALoCoQlBLQrq4A08ScwW4lGXRujhf3KLhW7FZvunPSTRD5/aZW0WXqReSp71U0eM27rhtNDb+bXn X-Received: by 10.224.88.71 with SMTP id z7mr6386122qal.94.1406723274443; Wed, 30 Jul 2014 05:27:54 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id t23sm2384767qge.13.2014.07.30.05.27.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:27:53 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH 07/37] nfsd: Protect nfsd4_destroy_clientid using client_lock Date: Wed, 30 Jul 2014 08:27:08 -0400 Message-Id: <1406723258-8512-8-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406723258-8512-1-git-send-email-jlayton@primarydata.com> References: <1406723258-8512-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Trond Myklebust ...instead of relying on the client_mutex. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 52a4677f6f35..68383b09c7dc 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2826,22 +2826,23 @@ nfsd4_sequence_done(struct nfsd4_compoundres *resp) __be32 nfsd4_destroy_clientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_destroy_clientid *dc) { - struct nfs4_client *conf, *unconf, *clp; + struct nfs4_client *conf, *unconf; + struct nfs4_client *clp = NULL; __be32 status = 0; struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); nfs4_lock_state(); + spin_lock(&nn->client_lock); unconf = find_unconfirmed_client(&dc->clientid, true, nn); conf = find_confirmed_client(&dc->clientid, true, nn); WARN_ON_ONCE(conf && unconf); if (conf) { - clp = conf; - if (client_has_state(conf)) { status = nfserr_clientid_busy; goto out; } + clp = conf; } else if (unconf) clp = unconf; else { @@ -2849,12 +2850,16 @@ nfsd4_destroy_clientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *csta goto out; } if (!mach_creds_match(clp, rqstp)) { + clp = NULL; status = nfserr_wrong_cred; goto out; } - expire_client(clp); + unhash_client_locked(clp); out: + spin_unlock(&nn->client_lock); nfs4_unlock_state(); + if (clp) + expire_client(clp); return status; }