Return-Path: Received: from mail-dm3nam03on0107.outbound.protection.outlook.com ([104.47.41.107]:39081 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932225AbeAXEP0 (ORCPT ); Tue, 23 Jan 2018 23:15:26 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Trond Myklebust , "J . Bruce Fields" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 058/100] nfsd: Ensure we check stateid validity in the seqid operation checks Date: Wed, 24 Jan 2018 04:14:54 +0000 Message-ID: <20180124041414.32065-58-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: 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 --- 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 5ec0ca5cbc1e..c927dbc8f490 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5184,15 +5184,9 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_comp= ound_state *cstate, stateid_ status =3D nfsd4_check_seqid(cstate, sop, seqid); if (status) return status; - if (stp->st_stid.sc_type =3D=3D NFS4_CLOSED_STID - || stp->st_stid.sc_type =3D=3D 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 =3D nfsd4_lock_ol_stateid(stp); + if (status !=3D nfs_ok) + return status; status =3D check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nf= sd4_has_session(cstate)); if (status =3D=3D nfs_ok) status =3D nfs4_check_fh(current_fh, &stp->st_stid); --=20 2.11.0