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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF1C1CA0FE6 for ; Fri, 1 Sep 2023 06:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348398AbjIAGtY (ORCPT ); Fri, 1 Sep 2023 02:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348397AbjIAGtY (ORCPT ); Fri, 1 Sep 2023 02:49:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DC2DE7E; Thu, 31 Aug 2023 23:49:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PA+yNU4lPn9KieY83YfnLjgiFKNzsnzdpdHO0b2nVFs=; b=CcIUGfC6963GwJ4rFhGTRJxf5i u5bGK54JOuEuzE9vY5sPmxb7Rd8MR+iSFQftbM01j2aL3KLkkHKzaVFDc1sAFy7/7fWOwRrZWDHoD 8VyyHPjgscpxr9vCqpUTVeDmDQZX1y6sgM9OwvQ0jsjCbnpWnooOqbo4bPSby/Z1UnMBP9Z6i9iWQ 8o6zhlX/ru1bFvG7M40SsHyOvo3a+0m0SXSLTeJwtPF6DbHSdjMKJDHpxdAjI4jyexPVNCR4WW7ao 8MWHiD/z6zkjigjTvpCkSosd0L+K9R8WCYnkOHbbm82FTLz9f356DZghcxlEzIxBwy0e2+e20ll0u hvJa4nug==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qbxy4-00GZ85-2F; Fri, 01 Sep 2023 06:49:20 +0000 Date: Thu, 31 Aug 2023 23:49:20 -0700 From: Christoph Hellwig To: Mateusz Guzik Cc: Bernd Schubert , linux-fsdevel@vger.kernel.org, bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Josef Bacik , linux-btrfs@vger.kernel.org, Alexander Viro , Christian Brauner Subject: Re: [PATCH 0/2] Use exclusive lock for file_remove_privs Message-ID: References: <20230830181519.2964941-1-bschubert@ddn.com> <20230831101824.qdko4daizgh7phav@f> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230831101824.qdko4daizgh7phav@f> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Aug 31, 2023 at 12:18:24PM +0200, Mateusz Guzik wrote: > Turns out notify_change has the following: > WARN_ON_ONCE(!inode_is_locked(inode)); > > Which expands to: > static inline int rwsem_is_locked(struct rw_semaphore *sem) > { > return atomic_long_read(&sem->count) != 0; > } > > So it does check the lock, except it passes *any* locked state, > including just readers. > > According to git blame this regressed from commit 5955102c9984 > ("wrappers for ->i_mutex access") by Al -- a bunch of mutex_is_locked > were replaced with inode_is_locked, which unintentionally provides > weaker guarantees. > > I don't see a rwsem helper for wlock check and I don't think it is all > that beneficial to add. Instead, how about a bunch of lockdep, like so: Yes, that's a good idea.