Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2050654ybk; Mon, 11 May 2020 10:40:01 -0700 (PDT) X-Google-Smtp-Source: APiQypIuGdsUxuWVRPmWTHZwjo83cPm6vtN/DRwMkbqcaphezMcbdTV6vMHtP+r+Cf1RiR++w3I/ X-Received: by 2002:a17:906:a3ca:: with SMTP id ca10mr14837742ejb.298.1589218801340; Mon, 11 May 2020 10:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589218801; cv=none; d=google.com; s=arc-20160816; b=t8rDYbYTb3r4GLHyAho8Yu1IVkY5cVCBz0MYKR+rbo452dDCv1lex1d6XKw+ar1WQx dfkMj9hBU1TGIVUWm3RzEYUqTCANdHk/BH6PUpOdjQvR0jiBfWzCbEa2shloxtb5vOx5 1pULwLoF0JQaqPRokBzSmkjBuYcd0KinryivmBxj66xJ9ziSoBWsFcBAOT3lCnvdSmbx ZY+PWA3Nl4IE3NmZsC1qeNJY7jHyqYJB1B4HR+S+Gf52ObSv47AiEQo1RHgRrIgh/UES MKbLQ1AmPKR4sI7X3OXhyHuK+ZcmYuBOYWWS2Z9gNazmV2QtZu/wF78MZzNp0l7z6hcI ONzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mfkPSE6U3JCnxLajh9TnsdYQqDMEcjdYVMDixWdKa54=; b=dsTpY3iHbMKkbAtS29HNBLQB/fzp6HA9ppBaZ9Tr9R1mOixj0U3PG+1oXzoLmFmh6F D83X7/HnDWrD4+17mv9ziW0DVABG93ggvs9LxNP6zET5lBGoDX6VWF5nWjN019BnV+Kk VKvc5cFFSN6yadnzoUV3leNlKskdEq5/Gman2jmX3UlERNxpxIYG/L9p0o4+7y6M6f5c XhptKQPS6WQYrOxvUylxpR+v5yOQpqQPZXYcqPqQlQygMN7UMpdtAdUr92aKDhe0jNYN sSoGNLA+F882WkIxwnCw/iCOcSm/zoVMpBJVIbw7ySCnxdihEvA9XuapT7FYfFzhjBPx 04jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si6144520ejz.335.2020.05.11.10.39.37; Mon, 11 May 2020 10:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730624AbgEKRjc (ORCPT + 99 others); Mon, 11 May 2020 13:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730215AbgEKRjc (ORCPT ); Mon, 11 May 2020 13:39:32 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00::f03c:91ff:fe50:41d6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A07C061A0C for ; Mon, 11 May 2020 10:39:32 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 6F347709; Mon, 11 May 2020 13:39:31 -0400 (EDT) Date: Mon, 11 May 2020 13:39:31 -0400 From: "bfields@fieldses.org" To: Masayoshi Mizuma Cc: Trond Myklebust , "schumakeranna@gmail.com" , "linux-nfs@vger.kernel.org" Subject: Re: [PATCH] nfs: fix NULL deference in nfs4_get_valid_delegation Message-ID: <20200511173931.GH8629@fieldses.org> References: <20200508221935.GA11225@fieldses.org> <20200511121054.l2j34vnwqxhvd2ao@gabell> <20200511131637.GA8629@fieldses.org> <8f9f84f11df6f5caf054d1eada2d91ea158a6882.camel@hammerspace.com> <20200511135745.GB8629@fieldses.org> <20200511140158.GD8629@fieldses.org> <20200511140248.GE8629@fieldses.org> <20200511173723.3xlqhkmrjbuc5g7r@gabell> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200511173723.3xlqhkmrjbuc5g7r@gabell> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, May 11, 2020 at 01:37:23PM -0400, Masayoshi Mizuma wrote: > Hello, > > How about adding Cc: stable@vger.kernel.org in the sign-off area? > 9ae075fdd190 "NFSv4: Convert open state lookup to use RCU" was merged Makes sense to me. I'll leave it to Trond.--b. > to v4.20 and some stable tree have 9ae075fdd190. > > On Mon, May 11, 2020 at 10:02:48AM -0400, bfields@fieldses.org wrote: > > From: "J. Bruce Fields" > > > > We add the new state to the nfsi->open_states list, making it > > potentially visible to other threads, before we've finished initializing > > it. > > > > That wasn't a problem when all the readers were also taking the i_lock > > (as we do here), but since we switched to RCU, there's now a possibility > > that a reader could see the partially initialized state. > > > > Symptoms observed were a crash when another thread called > > nfs4_get_valid_delegation() on a NULL inode, resulting in an oops like: > > > > BUG: unable to handle page fault for address: ffffffffffffffb0 ... > > RIP: 0010:nfs4_get_valid_delegation+0x6/0x30 [nfsv4] ... > > Call Trace: > > nfs4_open_prepare+0x80/0x1c0 [nfsv4] > > __rpc_execute+0x75/0x390 [sunrpc] > > ? finish_task_switch+0x75/0x260 > > rpc_async_schedule+0x29/0x40 [sunrpc] > > process_one_work+0x1ad/0x370 > > worker_thread+0x30/0x390 > > ? create_worker+0x1a0/0x1a0 > > kthread+0x10c/0x130 > > ? kthread_park+0x80/0x80 > > ret_from_fork+0x22/0x30 > > > > Fixes: 9ae075fdd190 "NFSv4: Convert open state lookup to use RCU" > > Cc: stable@vger.kernel.org # 4.20.x- > > Thanks! > Masa > > > Reviewed-by: Seiichi Ikarashi > > Tested-by: Daisuke Matsuda > > Tested-by: Masayoshi Mizuma > > Signed-off-by: J. Bruce Fields > > --- > > fs/nfs/nfs4state.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > I do have a patch including the tags and oops provided by Masayoshi > > > Mizuma, if you'd like to take that instead. See followup.--b. > > > > Here you go. > > > > diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c > > index f7723d221945..459c7fb5d103 100644 > > --- a/fs/nfs/nfs4state.c > > +++ b/fs/nfs/nfs4state.c > > @@ -734,9 +734,9 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner) > > state = new; > > state->owner = owner; > > atomic_inc(&owner->so_count); > > - list_add_rcu(&state->inode_states, &nfsi->open_states); > > ihold(inode); > > state->inode = inode; > > + list_add_rcu(&state->inode_states, &nfsi->open_states); > > spin_unlock(&inode->i_lock); > > /* Note: The reclaim code dictates that we add stateless > > * and read-only stateids to the end of the list */ > > -- > > 2.26.2 > >