Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3220782pxy; Mon, 3 May 2021 18:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMKF/bAh2VU0xYU5dsFBLG32Bs69PGScf0tcoDEE1bhtdDrZ5UV64Yt1d3cDU7x5jUmNhX X-Received: by 2002:a63:e443:: with SMTP id i3mr21392951pgk.114.1620093467671; Mon, 03 May 2021 18:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620093467; cv=none; d=google.com; s=arc-20160816; b=iJXFJYVPOrRA6MnybR2Wi7+FToC6M5kKdZLlVw22LncJyHrJSBq+xeKdekTqr/aptL QBAkAT+YbBTfoTgGcyTKzdEBVho/NxmnuagMRuke/tkrM4kzKMltlpFBFbctweM9dKzy PAJYX1gu6Imtzuias6d/+eM5ubwWoB+GY7cxiEHC9TvqaPsT6sRsk9QVkNGH68xSQMmj nf7i0WD+zx4zmK8IW+Biq04MS/c4fMi7flYR2vBsl8pb6niXnY6yd4fshrY0cQG2t+KI qPRlZxctSRRsYgAOFMzIxU7VkyODMaG1h/3BDD78nhjsSZoO6y2n33cv/2du+g6hW/HE jtMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=deh0rXAe7/t2AuhkDU2bSg6vapmNvmDAjbPrH6/fQW8=; b=wCY5RpITepFCTtPVsYTQxK1BI25pCszCFWAEyPET1/sQz/ZmMOgPTEoYnq4u9ic0eX PuzewYCeB4MIvVvKbny7m59ZJ/yekcg8itNiF1Kak/PAmOyrIjQ9yvaJk/fO0fHAx1fQ 8Nnq/GTwIrA66VujxLJSc7FyM+Bm9R6nPzXRxaf7Fo6neClLv4qEMoCv1h295fSj0w6L nGtUxDKi1sEahTG1iEYXfkQ7gSoPRqgEnYz2aL/Q1J34MYey5UFSDNkssRs5gEnYIi3v sT5AzYmelh+J+j2aVhrrZvwSs8SZ8VeGn5Ew0q5lMvx00/xQaMsqOa69pkIDWYTvZ5F2 ATww== 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 b9si1865084pgh.123.2021.05.03.18.57.32; Mon, 03 May 2021 18:57:47 -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 S229649AbhEDB4n (ORCPT + 99 others); Mon, 3 May 2021 21:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhEDB4n (ORCPT ); Mon, 3 May 2021 21:56:43 -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 829C8C061574; Mon, 3 May 2021 18:55:49 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1ldkHm-00ApeZ-PB; Tue, 04 May 2021 01:55:42 +0000 Date: Tue, 4 May 2021 01:55:42 +0000 From: Al Viro To: Linus Torvalds Cc: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List Subject: Re: [GIT PULL] gpio: updates for v5.13 Message-ID: References: <20210502193216.24872-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 03, 2021 at 06:28:38PM +0000, Al Viro wrote: > > So Al, do you see anything horrendous in how that configfs thing uses > > a rename to do kind of an "atomic swap" of configfs state? > > Give me a few hours; configfs is playing silly buggers with a lot of > structures when creating/tearing down subtrees, and I'd actually > expect more trouble with configfs data structures than with VFS ones. > > I'll take a look. FWIW, one obviously bogus thing is this: + spin_lock(&configfs_dirent_lock); + new_dentry->d_fsdata = sd; + list_move(&sd->s_sibling, &new_parent_sd->s_children); + item->ci_parent = new_parent_item; + d_move(old_dentry, new_dentry); + spin_unlock(&configfs_dirent_lock); on successful ->rename(). sd here comes from + sd = old_dentry->d_fsdata; Now, take a look at configfs_d_iput(). ->d_fsdata contributes to refcount of sd, and I don't see anything here that would grab the reference. Incidentally, if your code critically depends upon some field being first in such-and-such structure, you should either get rid of the dependency or at least bother to document that. That + /* + * Free memory allocated for the pending and live directories + * of committable groups. + */ + if (sd->s_type & (CONFIGFS_GROUP_PENDING | CONFIGFS_GROUP_LIVE)) + kfree(sd->s_element); + is asking for trouble down the road. I dislike (for the lack of adequate printable terms) the way configfs deals with subtree creation and, especially, removal. It's kept attached to dentry tree (all the way to the root) as we build it and, in case we fail halfway through, as we are trying to take it apart. There is convoluted code trying to prevent breakage in such cases, but it's complex, brittle and I don't remember how critical the lack of renames had been in its analysis. I can try to redo that, but that would take some time - IIRC, the last time I did it, it took several days of work (including arseloads of grepping through configfs users and doing RTFS in those) IMO we should attach the subtree we'd built only when it's fully set up. I can dig out the notes (from 2 years ago) on how to massage the damn thing in that direction, but again, it'll take a day or two to verify that analysis still applies. OTOH, that would simplify the code considerably, so the next time we want to change something it wouldn't be so unpleasant.