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 S932246AbeAXEP2 (ORCPT ); Tue, 23 Jan 2018 23:15:28 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Andrew Elble , "J . Bruce Fields" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 060/100] nfsd: check for use of the closed special stateid Date: Wed, 24 Jan 2018 04:14:55 +0000 Message-ID: <20180124041414.32065-60-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: Andrew Elble [ Upstream commit ae254dac721d44c0bfebe2795df87459e2e88219 ] Prevent the use of the closed (invalid) special stateid by clients. Signed-off-by: Andrew Elble Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/nfs4state.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c927dbc8f490..cc74fb0dc02d 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -72,6 +72,7 @@ static u64 current_sessionid =3D 1; #define ZERO_STATEID(stateid) (!memcmp((stateid), &zero_stateid, sizeof(st= ateid_t))) #define ONE_STATEID(stateid) (!memcmp((stateid), &one_stateid, sizeof(sta= teid_t))) #define CURRENT_STATEID(stateid) (!memcmp((stateid), ¤tstateid, size= of(stateid_t))) +#define CLOSE_STATEID(stateid) (!memcmp((stateid), &close_stateid, sizeof= (stateid_t))) =20 /* forward declarations */ static bool check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *l= owner); @@ -4869,7 +4870,8 @@ static __be32 nfsd4_validate_stateid(struct nfs4_clie= nt *cl, stateid_t *stateid) struct nfs4_stid *s; __be32 status =3D nfserr_bad_stateid; =20 - if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid) || + CLOSE_STATEID(stateid)) return status; /* Client debugging aid. */ if (!same_clid(&stateid->si_opaque.so_clid, &cl->cl_clientid)) { @@ -4927,7 +4929,8 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cst= ate, else if (typemask & NFS4_DELEG_STID) typemask |=3D NFS4_REVOKED_DELEG_STID; =20 - if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid) || + CLOSE_STATEID(stateid)) return nfserr_bad_stateid; status =3D lookup_clientid(&stateid->si_opaque.so_clid, cstate, nn); if (status =3D=3D nfserr_stale_clientid) { --=20 2.11.0