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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B598AC4338F for ; Wed, 25 Aug 2021 05:19:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 948BC6128A for ; Wed, 25 Aug 2021 05:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbhHYFT5 (ORCPT ); Wed, 25 Aug 2021 01:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhHYFT4 (ORCPT ); Wed, 25 Aug 2021 01:19:56 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60530C061757 for ; Tue, 24 Aug 2021 22:19:11 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIlJY-00FqEt-Gy; Wed, 25 Aug 2021 05:19:04 +0000 Date: Wed, 25 Aug 2021 05:19:04 +0000 From: Al Viro To: Christoph Hellwig Cc: "Gong, Sishuai" , "jlbec@evilplan.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] configfs: fix a race in configfs_lookup() Message-ID: 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: <20210823170847.GA617@lst.de> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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?