From patchwork Tue Oct 31 00:09:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10033491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C4866039A for ; Tue, 31 Oct 2017 00:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E57D28945 for ; Tue, 31 Oct 2017 00:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1343728990; Tue, 31 Oct 2017 00:10:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 077D828945 for ; Tue, 31 Oct 2017 00:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527AbdJaAKD (ORCPT ); Mon, 30 Oct 2017 20:10:03 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:49141 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753286AbdJaAKC (ORCPT ); Mon, 30 Oct 2017 20:10:02 -0400 Received: by mail-io0-f195.google.com with SMTP id j17so31213124iod.5 for ; Mon, 30 Oct 2017 17:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h5E6uHOuNbGJSxP0Xh3Zy9KcN4CXxM6CIvBQL3csd0s=; b=HRgWwVqwge9MfEIYqhp5s5iLOdAZn94Rsx2u9jPQMVPFs2TCUSofQDv/YsewG5otdu /lZuiNGR6mx3AQncXO83yoPfyZQOdsUQ21/W/i/Ih06qnzquZrP8WIAyM68fBCYspxww DwSe1PgcZOdxuCIb3MpZZEjj/zZBPa5PaF1FeSbsiOMuPgpIafSE1OHe6gmC8Zur1V/3 CQ9ZoHFFDgyXqFz5532oqvaZsufASsurufXm+58Ja3Gy0wpQXdoq1y/XoXQa3ACuv5bN TI3bzpmHds2OlKG9Vovth81MO8ZvxUE9Sau0a4n3lrjEUEGW3C/vzXnTL9BqtioJKsPZ hX7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=h5E6uHOuNbGJSxP0Xh3Zy9KcN4CXxM6CIvBQL3csd0s=; b=mIFWFUTircOScT8E1MVeO48Qp+3nC8rolzkqx462McyqA+hoZgyojJKhIigpBB0Odu H0eYvDxuG8larPBkRWk3zCnNtfLSrd9jeDl5/V3iDNSyVwiGEGtOpSK4tbfnU2JaIF1s 4rKh0pz1Q67M/TLE7XYc9Z7v5OFjWd+KHenxFRBfiQdCo/A6Az2ARKXRJrZ6pk0J9Nkx YjjJDYNSBsw3f6aNe3LXZiVhlci9sZvdGFYCrMCiNqdF1bhgTbrUnyuFQ5u23Av4Pgbr owQl8FrXz9xdmeTWKxA/PqnoZ5+ix+iyCUAAfZmVQxxnNdAmzY+kypxJFieNG/a8YIf9 5r6w== X-Gm-Message-State: AMCzsaV3Xo5+BzfEyI+OLrycN/0HMLPEotPvrrhiYBrNePFtmWbPPmwV bVmDfGqHpclUIKi53yYDmKVU77w= X-Google-Smtp-Source: ABhQp+RRo3a3kd9TO5xvR+Dq5zy8/9JWHq9Kj+oFbVxOn4edgu9DvDtnGAnin4VV9nIpYpjQ+URSQg== X-Received: by 10.107.170.29 with SMTP id t29mr145130ioe.73.1509408601872; Mon, 30 Oct 2017 17:10:01 -0700 (PDT) Received: from localhost.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id h97sm63653iod.87.2017.10.30.17.09.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2017 17:10:00 -0700 (PDT) From: Trond Myklebust To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/5] nfsd: Ensure we check stateid validity in the seqid operation checks Date: Mon, 30 Oct 2017 20:09:50 -0400 Message-Id: <20171031000951.18294-5-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171031000951.18294-4-trond.myklebust@primarydata.com> References: <20171031000951.18294-1-trond.myklebust@primarydata.com> <20171031000951.18294-2-trond.myklebust@primarydata.com> <20171031000951.18294-3-trond.myklebust@primarydata.com> <20171031000951.18294-4-trond.myklebust@primarydata.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After taking the stateid st_mutex, we want to know that the stateid still represents valid state before performing any non-idempotent actions. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cc8fff93146d..ab56d265ef68 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5163,15 +5163,9 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ status = nfsd4_check_seqid(cstate, sop, seqid); if (status) return status; - if (stp->st_stid.sc_type == NFS4_CLOSED_STID - || stp->st_stid.sc_type == NFS4_REVOKED_DELEG_STID) - /* - * "Closed" stateid's exist *only* to return - * nfserr_replay_me from the previous step, and - * revoked delegations are kept only for free_stateid. - */ - return nfserr_bad_stateid; - mutex_lock(&stp->st_mutex); + status = nfsd4_lock_ol_stateid(stp); + if (status != nfs_ok) + return status; status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); if (status == nfs_ok) status = nfs4_check_fh(current_fh, &stp->st_stid);