Received: by 10.223.176.5 with SMTP id f5csp978712wra; Fri, 2 Feb 2018 09:10:13 -0800 (PST) X-Google-Smtp-Source: AH8x226AiiMxb0RK9UWc4S5XMuXn5403KOXX0JasPt4xEQWCMaO/cHGfCBLGh+H2oklTfOIRv+td X-Received: by 10.99.105.202 with SMTP id e193mr1305416pgc.239.1517591413050; Fri, 02 Feb 2018 09:10:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591413; cv=none; d=google.com; s=arc-20160816; b=Y70KOaJA9cbAgTunk3AWPYK1tpsp7yUh2SrNS3rWA0eyKhak5KjSRURwcdDT2Y8Qkp QmtpnpgKgrptGQLMTmjoY5xMB4ltEoVp4cVn6rtPIZG2Wgfi3RKsiu7JRqKk0xSxx7P/ dfHx7Ont/SU4r9VwRsYae6ak1uuUNGrnQp3NdqVTk5uKcayRlv9hXIJkTRju/x+fnWS2 lJJb2GTmavHacVoJvSrQ4edb+pHilZBXa1Q7mThqUpLw6UMgLsKPPo/TXctnkC3Guc1G uRK4wRWTj7/e9YvGPycSpCu20SE/fptDX454Eu0hqDZRbF1uQ8n/tIHNVeeXVYgeW39/ DAOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bMWkEZJNqrt5/V/0entxzlqrmDi8iosN6k19ofRIQb0=; b=XCuM1x0T6Lmbxic+gaiGZty/MhiLn6l360jg4oozaZ04V0gzzf5toOKNCUu97LSBQM g+7nWrxjw81suQJAMNntqyo0/aC2XdJxDHnuZqIXqChIBkSgd1kmnuUtQZt9YI1hH0s8 ANyIrFRkxzEgUKkkPUGx8yfBchhouVhBElMcsteeE8Zk8Z33Km3aACQLJBjFXMUNqqeb OZjaud1HuxvqyJid4XLdsuVINLL8MU793ncL5HSuVyx2co8zHdlrJRQgN6uU6GsoULyd IAlePIWxgxcjv7mDXqOdmLkg1b/doiZGAmYle4wn/UjexKpXW6cys/yQt5pNhFVEuqlj wYEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si98845pgr.460.2018.02.02.09.09.58; Fri, 02 Feb 2018 09:10:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753199AbeBBRIJ (ORCPT + 99 others); Fri, 2 Feb 2018 12:08:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36252 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbeBBREe (ORCPT ); Fri, 2 Feb 2018 12:04:34 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1F383DB7; Fri, 2 Feb 2018 17:04:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 4.9 42/86] nfsd: Ensure we check stateid validity in the seqid operation checks Date: Fri, 2 Feb 2018 17:58:02 +0100 Message-Id: <20180202140826.248482724@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Trond Myklebust [ Upstream commit 9271d7e509c1bfc0b9a418caec29ec8d1ac38270 ] 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 Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5178,15 +5178,9 @@ static __be32 nfs4_seqid_op_checks(struc 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);