From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 175FFC4338F for ; Wed, 25 Aug 2021 05:29:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB53261100 for ; Wed, 25 Aug 2021 05:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232290AbhHYF3u (ORCPT ); Wed, 25 Aug 2021 01:29:50 -0400 Received: from verein.lst.de ([213.95.11.211]:54736 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhHYF3s (ORCPT ); Wed, 25 Aug 2021 01:29:48 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id EE8D96736F; Wed, 25 Aug 2021 07:29:00 +0200 (CEST) Date: Wed, 25 Aug 2021 07:29:00 +0200 From: Christoph Hellwig To: Al Viro Cc: Christoph Hellwig , "Gong, Sishuai" , "jlbec@evilplan.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] configfs: fix a race in configfs_lookup() Message-ID: <20210825052900.GA26714@lst.de> References: <20210820214458.14087-1-sishuai@purdue.edu> <20210823074636.GA23822@lst.de> <20210823170847.GA617@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 25, 2021 at 05:19:04AM +0000, Al Viro wrote: > On Mon, Aug 23, 2021 at 07:08:47PM +0200, Christoph Hellwig wrote: > > > We can't hold a spinlock over inode allocation. So it would have to be > > something like this: > > Check for -ENAMETOOLONG first; easier for analysis that way. Indeed. > > + dentry->d_fsdata = configfs_get(sd); > > + sd->s_dentry = dentry; > > + spin_unlock(&configfs_dirent_lock); > > > > - found = 1; > > - err = configfs_attach_attr(sd, dentry); > > - break; > > + inode = configfs_create(dentry, mode); > > + if (IS_ERR(inode)) { > > + configfs_put(sd); > > + return ERR_CAST(inode); > > Er... Won't that leave dentry with dangling ->d_fsdata? Yes. Existing problem, though.