Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp480300ybj; Wed, 6 May 2020 23:56:35 -0700 (PDT) X-Google-Smtp-Source: APiQypIIPTRu4qtXVHhceUPATr9pKJHrHyYhu/md3Mfv9//Q4SllAY9rZQTe56TmE6fhpmi2sV1/ X-Received: by 2002:a05:6402:3056:: with SMTP id bu22mr10550181edb.192.1588834594850; Wed, 06 May 2020 23:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588834594; cv=none; d=google.com; s=arc-20160816; b=XGFCFhqTovAJVe0RSEKEigWA0aC6UBpVLul5ZCdr4RZNVve1lxHrD+IjX5oom/t8ag 2f5sMHdBaUNLNt4PHO91ozvUc8O0pun1jNNA7H+W3MBiX29/h2tL2jZzG/Wv0/JpVvJG Vzp+mn4eJyO0IM+I0OWFxNRHkZwA43Mcb2arkRmZjWohtrCRRj9pLstnkaLRdvSA+o52 USpbQsEa56fRI5jgTs888XPv/QlyAybvAST3vgHCViSI2ryB0rAW9VCBd7n26cXfpSy4 B1VI7pnGQfCj3eojg32Eulujbb+VD5V6kZ+BTBaPOj2r1ra1PYgpfOfYod8VSnb6EsdV 3IpA== 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=B3rQZtwadMiX8uVgzZxxFQgOFh2qgE35u+ghF9hf5NE=; b=hbAuNRgaDiKYJGQxqOWgQN4jNeT7MbKZXn8VCx4B/DNJ/f5m+hx61zjfelAflVPavB gDa+scYzsXfTbNE0H4jp9PD+NaEt64T8uQ5WgLS+316EwdlLBAlZvYzdm54l4bnFYq3D I0ErEIVFFRUO+gMoBNXEFgoXio70azfixjtY65xDxq5j/PtJtj8XsSfALLpsvwjcw5V1 Z+dZv8unkBmD5wBXyCy4qynVAJp3CgHruIG/nNRaq54AhSRn7Nq0/tjXToGOY81tNeLC MiP+pYmBa0nWUVpbi2WUe3BGkTiXKBLeI5Yllg7WsOT9uIrhGNzEjhsyVbqzHO9ohDl6 7yLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 t12si2672361ejb.508.2020.05.06.23.56.11; Wed, 06 May 2020 23:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725849AbgEGGyz (ORCPT + 99 others); Thu, 7 May 2020 02:54:55 -0400 Received: from verein.lst.de ([213.95.11.211]:44911 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgEGGyy (ORCPT ); Thu, 7 May 2020 02:54:54 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 1010968B05; Thu, 7 May 2020 08:54:52 +0200 (CEST) Date: Thu, 7 May 2020 08:54:51 +0200 From: Christoph Hellwig To: Michael Ellerman Cc: Christoph Hellwig , linuxppc-dev@ozlabs.org, jk@ozlabs.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/spufs: Add rcu_read_lock() around fcheck() Message-ID: <20200507065451.GA6185@lst.de> References: <20200428114811.68436-1-mpe@ellerman.id.au> <20200428135245.GA2827@lst.de> <875zdifrgw.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875zdifrgw.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 29, 2020 at 09:42:39PM +1000, Michael Ellerman wrote: > Christoph Hellwig writes: > > On Tue, Apr 28, 2020 at 09:48:11PM +1000, Michael Ellerman wrote: > >> > >> This comes from fcheck_files() via fcheck(). > >> > >> It's pretty clearly documented that fcheck() must be wrapped with > >> rcu_read_lock(), so fix it. > > > > But for this to actually be useful you'd need the rcu read lock until > > your are done with the file (or got a reference). > > Hmm OK. My reasoning was that we were done with the struct file, because > we return the ctx that's hanging off the inode. > > + ctx = SPUFS_I(file_inode(file))->i_ctx; > > But I guess the lifetime of the ctx is not guaranteed if the file goes > away. > > It looks like the only long lived reference on the ctx is the one > taken in spufs_new_file() and dropped in spufs_evict_inode(). > > So if we take a reference to the ctx with the RCU lock held we should be > safe, I think. But I've definitely exhausted my spufs/vfs knowledge at > this point. > > Something like below. Looks reasonable.