From patchwork Thu Oct 19 00:48:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew W Elble X-Patchwork-Id: 10015657 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 8278860215 for ; Thu, 19 Oct 2017 00:55:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7384E28C2C for ; Thu, 19 Oct 2017 00:55:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64E9628C30; Thu, 19 Oct 2017 00:55:20 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 C24AD28C2C for ; Thu, 19 Oct 2017 00:55:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751217AbdJSAzS (ORCPT ); Wed, 18 Oct 2017 20:55:18 -0400 Received: from discipline.rit.edu ([129.21.6.207]:29898 "HELO discipline.rit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750946AbdJSAzS (ORCPT ); Wed, 18 Oct 2017 20:55:18 -0400 X-Greylist: delayed 401 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Oct 2017 20:55:18 EDT Received: (qmail 89101 invoked by uid 501); 19 Oct 2017 00:48:36 -0000 From: Andrew W Elble To: Benjamin Coddington Cc: Jeff Layton , Subject: Re: [PATCH] nfsd4: Prevent the reuse of a closed stateid References: <2087b4cab6c695a7df01c1135f1773c9b762f0b0.1508248427.git.bcodding@redhat.com> <1508258356.4747.6.camel@redhat.com> <1508264368.4747.17.camel@redhat.com> Date: Wed, 18 Oct 2017 20:48:36 -0400 In-Reply-To: (Benjamin Coddington's message of "Tue, 17 Oct 2017 16:40:05 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix) 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 Benjamin Coddington writes: > On 17 Oct 2017, at 14:19, Jeff Layton wrote: > >> Also we now have to take the st_mutex in nfsd4_find_existing_open, just to >> check sc_type. Neither of those are probably unreasonable, it's just >> messier than I'd like. > > It is indeed messy.. no argument. I'll spin up your suggestion to unhash > the stateid before updating and take it for a ride and let you know the > results. Thanks for looking at this. I threw this against a quick lockdep run and didn't see anything that surprised me. I think we developed a harmless warning in nfsd4_process_open2() a ways back? diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 94ef63a10146..87535f2688be 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -64,6 +64,9 @@ static const stateid_t currentstateid = { .si_generation = 1, }; +static const stateid_t invalidstateid = { + .si_generation = U32_MAX, +}; static u64 current_sessionid = 1; @@ -5362,11 +5365,11 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s) nfsd4_bump_seqid(cstate, status); if (status) goto out; - nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); - mutex_unlock(&stp->st_mutex); + memcpy(&close->cl_stateid, &invalidstateid, sizeof(stateid_t)); nfsd4_close_open_stateid(stp); + mutex_unlock(&stp->st_mutex); /* put reference from nfs4_preprocess_seqid_op */ nfs4_put_stid(&stp->st_stid); out: