From patchwork Thu Jun 19 14:50:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4384281 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A8282BEEAA for ; Thu, 19 Jun 2014 14:52:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3AD020384 for ; Thu, 19 Jun 2014 14:52:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9173C20396 for ; Thu, 19 Jun 2014 14:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757862AbaFSOwo (ORCPT ); Thu, 19 Jun 2014 10:52:44 -0400 Received: from mail-qc0-f169.google.com ([209.85.216.169]:40569 "EHLO mail-qc0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932295AbaFSOwn (ORCPT ); Thu, 19 Jun 2014 10:52:43 -0400 Received: by mail-qc0-f169.google.com with SMTP id c9so2299998qcz.0 for ; Thu, 19 Jun 2014 07:52:43 -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=ThxUXcLk2eHQ9YCaUBxUL3uC7QFnG2DKhcKgFXG6MEQ=; b=PgOKEBkPEFEWGlleeKZm2Pmp9VoudJjxlVJc0GsQ3nnLO7nfigW7IPmZkiP7Xs43d9 O93QfEUc+u7/lyYjEPpPLKAgnEFbB/+jSopsihbEJpXf11K1Zg0q7Qlpt0hG20+tXyb4 0nVsKPa/DFScCnAsgwTvCQrpuOjF8q8TFFDLiHTSLs3Wz8Mwa3+Da6KsZlG0fCDFq+9E Yse+rdHC2IakINrYTaVGI3+1tyLrRcp+mfFBa6l9PeZnjKYPLaKan9yzY5/xN0FnvOhZ 6LMjNwbGLKEBDbYl6vmGRinA0B5+GI2/U7XW48KHzsqRo7BeilO+vP1sjH6HAU72vDsB e2+Q== X-Gm-Message-State: ALoCoQkmP8mszfECbja/PsK6zlUl+E5d6anFXmYDrQaaTkCrbS+xDAzKLpxqUMa45PDRF4ZvZDcV X-Received: by 10.140.51.74 with SMTP id t68mr7588887qga.50.1403189563180; Thu, 19 Jun 2014 07:52:43 -0700 (PDT) Received: from tlielax.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id r60sm3364044qgd.26.2014.06.19.07.52.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jun 2014 07:52:42 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 073/104] NFSd: Protect nfsd4_destroy_clientid using client_lock Date: Thu, 19 Jun 2014 10:50:19 -0400 Message-Id: <1403189450-18729-74-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403189450-18729-1-git-send-email-jlayton@primarydata.com> References: <1403189450-18729-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 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 be84ac190052..955027d4dc85 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2647,22 +2647,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 { @@ -2670,12 +2671,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; }