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 F3913C83F10 for ; Thu, 31 Aug 2023 07:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237689AbjHaHku (ORCPT ); Thu, 31 Aug 2023 03:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbjHaHku (ORCPT ); Thu, 31 Aug 2023 03:40:50 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BCED1A3; Thu, 31 Aug 2023 00:40:46 -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=ccB2LVS/tUuk3eRzpdd7XrE+xJv3Lnyhqf1GwTcQim4=; b=jR3MbC+/65/URnB/bkJ1K/qbdS FHWnPkcvI8M4NbUoIEzjY6WKflMQKm05oQ1ylQ8VeKE8ftOzi74+Bbz85vbPirY1O9VK3Ob1YJuxb yChN3vf/qipA683IvOfGA45djmrelDJiiVWtdj29q4J+J3TBfihlHkGE3L8BqySU1SvrQcXSn335N 6vSxmSDeSxNOeSnRBpTApxN2v0g7RE9Ul1DWHobgJnCBMIhfC2HEEbw1MeUUKm+Q9yJJLObVQa2V3 HS06nRF7mJNgj60Y62zkjhJzXkebK2YxWnwcf/5lM5QEMcGNjXN0QdS7v62moRD9TRj838cKfWVng HGk2+pzA==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qbcIH-00EpUK-1a; Thu, 31 Aug 2023 07:40:45 +0000 Date: Thu, 31 Aug 2023 00:40:45 -0700 From: Christoph Hellwig To: Bernd Schubert Cc: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230830181519.2964941-1-bschubert@ddn.com> 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 Wed, Aug 30, 2023 at 08:15:17PM +0200, Bernd Schubert wrote: > While adding shared direct IO write locks to fuse Miklos noticed > that file_remove_privs() needs an exclusive lock. I then > noticed that btrfs actually has the same issue as I had in my patch, > it was calling into that function with a shared lock. > This series adds a new exported function file_needs_remove_privs(), > which used by the follow up btrfs patch and will be used by the > DIO code path in fuse as well. If that function returns any mask > the shared lock needs to be dropped and replaced by the exclusive > variant. FYI, xfs and ext4 use a simple IS_NOSEC check for this. That has a lot more false positives, but also is a much faster check in the fast path. It might be worth benchmarking which way to go, but we should be consistent across file systems for the behavior.