Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp178621rdg; Thu, 12 Oct 2023 02:22:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEovsmhnQDgP+ARFkFEIDtBsB4w9quKS7mqfHCBsfscy0wpkmUbmM4bOVnExbGhT80+y2wi X-Received: by 2002:a05:6e02:1d93:b0:349:296c:9b8a with SMTP id h19-20020a056e021d9300b00349296c9b8amr30768266ila.2.1697102571486; Thu, 12 Oct 2023 02:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697102571; cv=none; d=google.com; s=arc-20160816; b=wKjQYI/rSJ3bGWslpwB28DOUAljsL/fW4qPafrwjKimtDaRr4awBfb6INFoVDeZkZX oSReb0wXqaddSrUnIBpxCtnVCrvNyWWyYcLfWbqtAIYGGRbC+5jXisAk84DAbgoJrwFZ SUhBNkvIPeDujxHwIBl22U9/JG+/fSG8bV1PldsFm3aRDf7B0kkN/f3R3lEx6bLjf8yq BFwEP9hk+G5v45JAc8NsF8yv/dnSZ0BCleXapzymLFy9lIQprwzldE+uYNXqfdrVhN8W mz82+0DCuJ02lyS42Ta2+Yr7I1hwaScfvuJwcRLwB76YTZemgq3zRSNaBwpiHZINLItZ dXJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DFIwNS1wRZZs4N9XU6D4+uHSNBBg6ejyGYAiSpxUzQo=; fh=CG/j9sxxi5y2NGi49tuwL1uBzrhr6t6G0aN9sZkxwVU=; b=kNsISSiQNI17vVJrlFcYm/nBM5FKfq0lcaEOORbdKu0btaPmt21LvLaua9xi9ifGdi P/NNML0LAhNax5RHOcdL//Lnv7pMZL3zqfJoeAZ2E7hRanRdgosKkqDA/mM2OWcLm9dd OOIFFks/9p+hLR84GCEMl9EDHKTSK03BzUOCpj9IW5PhhUwuGWU8lY3/wTejzGYZ9jaJ T8UcEkEp5xAxu/qvEo5zFMxFqWA28x+yhnFAeK+0LitkL5IPuqFe5rYUnYB1Vp/hMS/T g5t+UrjLbapt0RHwwc6pt7K6sDagmmabWy2RfEq8EvCAu5aYrVGfjCXiSKmiY8uTZrIQ tX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pKX/2tP0"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q10-20020a63504a000000b005774d2f4ab5si1887548pgl.807.2023.10.12.02.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 02:22:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pKX/2tP0"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A1B9782250A6; Thu, 12 Oct 2023 02:22:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235529AbjJLJWj (ORCPT + 99 others); Thu, 12 Oct 2023 05:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235521AbjJLJWi (ORCPT ); Thu, 12 Oct 2023 05:22:38 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 961BEC4; Thu, 12 Oct 2023 02:22:35 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E70C433C8; Thu, 12 Oct 2023 09:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697102555; bh=AVoONaJXnEpXaoCQ4Sw9bA4Z6lJLX8sVavrkKsLMlV4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pKX/2tP058GU7x8IhDoq1zWDSz67wQdRrBFkfyFzw+5XOX+dtupVQknNEucodLxl7 YjXMy9X5QcB3P/V6ZFSx+IRYE9lDE2LAHHCXCK67C0CscqwQbOXhn5p9P8MmUKrB5p tut9kV50Boh4XBpZbOyDkT0XjJxQTGGucdYTcdkojcB+GQ02ZO8dTFzdccV/pbvLj/ Jsn8sFY7M/SRivqqGWWDhIwCH6pXbi+cDsmDmWnbvh3IhjnXS/+wDQfkTAdLbbg0cg mdfQhgwgKHjWlp/1B5/lB+EP9214EyC7D5zhYKaAlYfJBmDVbjXGJ6muJUABIgRT9Y xMcBUrZq81ejg== Date: Thu, 12 Oct 2023 11:22:29 +0200 From: Christian Brauner To: Jan Kara , Amir Goldstein Cc: Max Kellermann , Xiubo Li , Ilya Dryomov , Jeff Layton , Jan Kara , Dave Kleikamp , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, Yang Xu , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] fs/{posix_acl,ext2,jfs,ceph}: apply umask if ACL support is disabled Message-ID: <20231012-klebt-wahljahr-a29e40a2ea2a@brauner> References: <20231010131125.3uyfkqbcetfcqsve@quack3> <20231011100541.sfn3prgtmp7hk2oj@quack3> <20231011120655.ndb7bfasptjym3wl@quack3> <20231011135922.4bij3ittlg4ujkd7@quack3> <20231011-braumeister-anrufen-62127dc64de0@brauner> <20231011162904.3dxkids7zzspcolp@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231011162904.3dxkids7zzspcolp@quack3> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 02:22:46 -0700 (PDT) On Wed, Oct 11, 2023 at 06:29:04PM +0200, Jan Kara wrote: > On Wed 11-10-23 17:27:37, Christian Brauner wrote: > > On Wed, Oct 11, 2023 at 03:59:22PM +0200, Jan Kara wrote: > > > On Wed 11-10-23 14:27:49, Max Kellermann wrote: > > > > On Wed, Oct 11, 2023 at 2:18 PM Max Kellermann wrote: > > > > > But without the other filesystems. I'll resend it with just the > > > > > posix_acl.h hunk. > > > > > > > > Thinking again, I don't think this is the proper solution. This may > > > > server as a workaround so those broken filesystems don't suffer from > > > > this bug, but it's not proper. > > > > > > > > posix_acl_create() is only supposed to appy the umask if the inode > > > > supports ACLs; if not, the VFS is supposed to do it. But if the > > > > filesystem pretends to have ACL support but the kernel does not, it's > > > > really a filesystem bug. Hacking the umask code into > > > > posix_acl_create() for that inconsistent case doesn't sound right. > > > > > > > > A better workaround would be this patch: > > > > https://patchwork.kernel.org/project/linux-nfs/patch/151603744662.29035.4910161264124875658.stgit@rabbit.intern.cm-ag/ > > > > I submitted it more than 5 years ago, it got one positive review, but > > > > was never merged. > > > > > > > > This patch enables the VFS's umask code even if the filesystem > > > > prerents to support ACLs. This still doesn't fix the filesystem bug, > > > > but makes VFS's behavior consistent. > > > > > > OK, that solution works for me as well. I agree it seems a tad bit cleaner. > > > Christian, which one would you prefer? > > > > So it always bugged me that POSIX ACLs push umask stripping down into > > the individual filesystems but it's hard to get rid of this. And we > > tried to improve the situation during the POSIX ACL rework by > > introducing vfs_prepare_umask(). > > > > Aside from that, the problem had been that filesystems like nfs v4 > > intentionally raised SB_POSIXACL to prevent umask stripping in the VFS. > > IOW, for them SB_POSIXACL was equivalent to "don't apply any umask". > > Ah, what a hack... > > > And afaict nfs v4 has it's own thing going on how and where umasks are > > applied. However, since we now have the following commit in vfs.misc: > > > > commit f61b9bb3f8386a5e59b49bf1310f5b34f47bcef9 > > Author: Jeff Layton > > AuthorDate: Mon Sep 11 20:25:50 2023 -0400 > > Commit: Christian Brauner > > CommitDate: Thu Sep 21 15:37:47 2023 +0200 > > > > fs: add a new SB_I_NOUMASK flag > > > > SB_POSIXACL must be set when a filesystem supports POSIX ACLs, but NFSv4 > > also sets this flag to prevent the VFS from applying the umask on > > newly-created files. NFSv4 doesn't support POSIX ACLs however, which > > causes confusion when other subsystems try to test for them. > > > > Add a new SB_I_NOUMASK flag that allows filesystems to opt-in to umask > > stripping without advertising support for POSIX ACLs. Set the new flag > > on NFSv4 instead of SB_POSIXACL. > > > > Also, move mode_strip_umask to namei.h and convert init_mknod and > > init_mkdir to use it. > > > > Signed-off-by: Jeff Layton > > Message-Id: <20230911-acl-fix-v3-1-b25315333f6c@kernel.org> > > Signed-off-by: Christian Brauner > > > > I think it's possible to pick up the first patch linked above: > > > > fix umask on NFS with CONFIG_FS_POSIX_ACL=n doesn't lead to any > > > > and see whether we see any regressions from this. > > > > The second patch I can't easily judge that should go through nfs if at > > all. > > > > So proposal/question: should we take the first patch into vfs.misc? > > Sounds good to me. I have checked whether some other filesystem does not > try to play similar games as NFS and it appears not although overlayfs does > seem to play some games with umasks. I think that overlayfs sets SB_POSIXACL unconditionally to ensure that the upper filesystem can decide where the umask needs to be stripped. If the upper filesystem doesn't have SB_POSIXACL then the umask will be stripped directly in e.g., vfs_create(), and vfs_tmpfile(). If it does then it will be done in the upper filesystems. So with the patch I linked above that we have in vfs.misc we should be able to change overlayfs to behave similar to NFS: diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 9f43f0d303ad..361189b676b0 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1489,8 +1489,16 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_xattr = ofs->config.userxattr ? ovl_user_xattr_handlers : ovl_trusted_xattr_handlers; sb->s_fs_info = ofs; +#ifdef CONFIG_FS_POSIX_ACL sb->s_flags |= SB_POSIXACL; +#endif sb->s_iflags |= SB_I_SKIP_SYNC | SB_I_IMA_UNVERIFIABLE_SIGNATURE; + /* + * Ensure that umask handling is done by the filesystems used + * for the the upper layer instead of overlayfs as that would + * lead to unexpected results. + */ + sb->s_iflags |= SB_I_NOUMASK; err = -ENOMEM; root_dentry = ovl_get_root(sb, ctx->upper.dentry, oe); Which means that umask handling will be done by the upper filesystems just as is done right now and overlayfs can stop advertising SB_POSIXACL support on a kernel that doesn't have support for it compiled in. How does that sound?