From patchwork Fri Apr 15 11:02:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 561952 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 768B8C43217 for ; Fri, 15 Apr 2022 10:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352044AbiDOKEn (ORCPT ); Fri, 15 Apr 2022 06:04:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352028AbiDOKEm (ORCPT ); Fri, 15 Apr 2022 06:04:42 -0400 Received: from mail1.bemta36.messagelabs.com (mail1.bemta36.messagelabs.com [85.158.142.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60A7BB096; Fri, 15 Apr 2022 03:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1650016932; i=@fujitsu.com; bh=YW2t31SigmRnYDSTgB+T1pJcLO8aD2sH2Tq7Mun3OFc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kx1S6IfwrNptAnxOZNBs2rUbCoMO5nDfeqdG5YaHFBsgvurrQvuK+v5olv357rKsj JGypxZpZP8ykQS6qsfTdQYVukQH765B/w0apyIcBq+vHGZn8y4R/2DCxRlUtZeaM5C nPVH8dEDIDZP/LFCPpe3nzpH0X3feITqsVf/7YLXbqzTf7b4siG6/9bJJzAhVGZW3S HWyruIJcXvHsN4/m1HxD98WLJWtMajmW3pUd1oFz34zRx3bNwcWo8GsHN+0mLxU2zE A91+kcpueuKjDTstvAzwPz2AdDr5PIWdanzzL6y20yK+bxCQksPQb+VvWJR1cEV1cg N8DOoz9YY220Q== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileJIrShJLcpLzFFi42Kxs+GYpLvYKTL J4O8OBYvXhz8xWny4OYnJYsuxe4wWl5/wWfxctordYs/ekywWFw6cZrXY9WcHu8X5v8dZHTg9 Ti2S8Ni0qpPN4/MmOY9NT94yBbBEsWbmJeVXJLBmLP2znLFgPlvFrkPzmBsY17F2MXJxCAlsY ZT4v2Y7cxcjJ5CzgEli15wciMQeRolrrd/YQBJsApoSzzoXgBWJCLhILJywnhGkiFngCqPE9f Y5YAlhAS+JPVsaWUFsFgFViV1T94PZvAKeEt9nfGUBsSUEFCSmPHwPVM/BwQlU//9sLcRiT4m pky6zQZQLSpyc+QSsnFlAQuLgixfMEK2KEpc6vjFC2BUSs2a1MUHYahJXz21insAoOAtJ+ywk 7QsYmVYx2iUVZaZnlOQmZuboGhoY6BoamuqaWeoamprpJVbpJuqlluomp+aVFCUCpfUSy4v1U ouL9Yorc5NzUvTyUks2MQKjJqXYdc4Oxgt9P/UOMUpyMCmJ8r4VjUwS4kvKT6nMSCzOiC8qzU ktPsQow8GhJMH71x4oJ1iUmp5akZaZA4xgmLQEB4+SCG+oNVCat7ggMbc4Mx0idYpRUUqcVxg Y90ICIImM0jy4NljSuMQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmPebI9AUnsy8Erjpr4AW MwEt/rYqFGRxSSJCSqqBqbxFOvPIlul5siv0wreIlL09k2OS9lT48/K/vb53bY27ylq0azPP+ md7reWJ3JhyzDVGRnBeg9x7/s1tzzXqLZdnVtVoGl7u71AWavJQXe7wSKQ5t+Bo4ylZ/0+vu6 c6iC5w2fwy1DPw4S/Hm/dXcvy4d3nvnsVNf508vC6f+bn++edLRX55FbkFf3uOGByKUzvIUmr Wo+trsNGbs/qbo9cHW6Z1JhfVz/Q+ct1TtTNab6HPFqlY36prxofZrTYbGyrL6O7g05226EJC uu4djTWb19us7VSzbXhd2B2qaymsIv3x4EOHCSeVxef4PXQ6sa++0vvaQRXHbXP7Z7zenbj5W 5ak2tfY2xzqC22UWIozEg21mIuKEwHD8+6ylQMAAA== X-Env-Sender: xuyang2018.jy@fujitsu.com X-Msg-Ref: server-8.tower-532.messagelabs.com!1650016931!56198!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.85.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29816 invoked from network); 15 Apr 2022 10:02:11 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-8.tower-532.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Apr 2022 10:02:11 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 08451100478; Fri, 15 Apr 2022 11:02:11 +0100 (BST) Received: from R01UKEXCASM126.r01.fujitsu.local (unknown [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id EF9B6100471; Fri, 15 Apr 2022 11:02:10 +0100 (BST) Received: from localhost.localdomain (10.167.220.84) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 15 Apr 2022 11:02:00 +0100 From: Yang Xu To: , , CC: , , , , , , Yang Xu Subject: [PATCH v3 2/7] fs/namei.c: Add missing umask strip in vfs_tmpfile Date: Fri, 15 Apr 2022 19:02:18 +0800 Message-ID: <1650020543-24908-2-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If underflying filesystem doesn't enable own CONFIG_FS_POSIX_ACL, then posix_acl_create can't be called. So we will miss umask strip, ie use ext4 with noacl or disblae CONFIG_EXT4_FS_POSIX_ACL. Reported-by: Christian Brauner (Microsoft) Signed-off-by: Yang Xu --- fs/namei.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 3f1829b3ab5b..bbc7c950bbdc 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3521,6 +3521,8 @@ struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, child = d_alloc(dentry, &slash_name); if (unlikely(!child)) goto out_err; + if (!IS_POSIXACL(dir)) + mode &= ~current_umask(); error = dir->i_op->tmpfile(mnt_userns, dir, child, mode); if (error) goto out_err; From patchwork Fri Apr 15 11:02:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 561951 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 8DB6BC4332F for ; Fri, 15 Apr 2022 10:02:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352070AbiDOKFQ (ORCPT ); Fri, 15 Apr 2022 06:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352075AbiDOKFN (ORCPT ); Fri, 15 Apr 2022 06:05:13 -0400 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E99BB096; Fri, 15 Apr 2022 03:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1650016963; i=@fujitsu.com; bh=P+f9EIyUEbljZpZHlSR64Os55fmb75i3xES1pwHH2Mo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f52fZ/6Q6Q8vmwWotVd+qslURKbGpSCXzOhJANQu8rxIQMzdvxk9HzflJV56l/PV1 t3vF2CzJp7XUVagcojTNFs2ltCcgkwxHsqhFFb52LaltnrnNorChf4fiHoNEojZF/c oPC7cnrsdjAH1G2oXltBgKuwhixO7wEGyo8nEjbmKPTrhWhGxw6TpQwLCnDjoEYT60 mdzXdUbNevzRTGpK7Rt2RWdUsu9EQgOKNY7+c/FtWBbSoK/aWbj9IXdS3fYVL1mg3s A86KC53AsjmmqUecFr0vqSPv3ODcX0YBjptBtn/UZc0/apQJwd2J29dyR/txVf3WG0 UR8oqOVIrSqUQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgleJIrShJLcpLzFFi42Kxs+FI1D3sFJl k8OQUo8Xrw58YLT7cnMRkseXYPUaLy0/4LH4uW8VusWfvSRaLCwdOs1rs+rOD3eL83+OsDpwe pxZJeGxa1cnm8XmTnMemJ2+ZAliiWDPzkvIrElgzJratZS/4y1Wx+mp4A+NCzi5GTg4hgS2ME t92eUHYC5gkuv/bdjFyAdl7GCX+bTrBApJgE9CUeNa5gBnEFhFwkVg4YT0jSBGzwBVGievtc8 ASwgKJEhc3LwRrYBFQlWh7+IsVxOYV8JRoa1jMBGJLCChITHn4Hqieg4NTwEvi/9laiMWeElM nXWaDKBeUODnzCdgYZgEJiYMvXjBDtCpKXOr4xghhV0jMmtUGNVJN4uq5TcwTGAVnIWmfhaR9 ASPTKkarpKLM9IyS3MTMHF1DAwNdQ0NTXWNLXVMjvcQq3US91FLd8tTiEl0gt7xYL7W4WK+4M jc5J0UvL7VkEyMwUlKK1U12MHav/Kl3iFGSg0lJlPetaGSSEF9SfkplRmJxRnxRaU5q8SFGGQ 4OJQnev/ZAOcGi1PTUirTMHGDUwqQlOHiURHhDrYHSvMUFibnFmekQqVOMuhxrGw7sZRZiycv PS5US5xUGpgAhAZCijNI8uBGwBHKJUVZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjCvMcgUnsy8 ErhNr4COYAI64tuqUJAjShIRUlINTFmfN1ys2lKjp1iRLRh9J2C9Uiez6KfZR3/uvf5ty9GLH IJ5RzM+l4bOzDn3xD5bZPnerrci8iUxjsGLmMv0F/xYJvSx435F7quzc1zdHDjPzW0KkZY89r hkdYjJzYeJB55Iyy3e57nLeJaJTPKNyH/ZpxWjO2Wrs6vaJX8r/503Zb++DH/L4YU6O1ccXXH 7ztZDVv/kthx87fs4m/Hb5Sldz3X+iX4x90hl677C+nLeyhWht9Um/51wsXnGBN+U6cYckwPF 9/zzvxe7Z6e3zROJKo/cLO/bzDqPG7vvxWz7PjGydV6XtIzF8ql/lC61NEZbh3SaGK56fq/bt q01VkA6Me+p0DR7+1y2T1fzE5VYijMSDbWYi4oTAcw7kSmbAwAA X-Env-Sender: xuyang2018.jy@fujitsu.com X-Msg-Ref: server-10.tower-548.messagelabs.com!1650016962!59551!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.85.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31119 invoked from network); 15 Apr 2022 10:02:43 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-10.tower-548.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Apr 2022 10:02:43 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 94DA21001A2; Fri, 15 Apr 2022 11:02:42 +0100 (BST) Received: from R01UKEXCASM126.r01.fujitsu.local (unknown [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id 86E7310004E; Fri, 15 Apr 2022 11:02:42 +0100 (BST) Received: from localhost.localdomain (10.167.220.84) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 15 Apr 2022 11:02:17 +0100 From: Yang Xu To: , , CC: , , , , , , Yang Xu Subject: [PATCH v3 3/7] xfs: Only do posix acl setup/release operation under CONFIG_XFS_POSIX_ACL Date: Fri, 15 Apr 2022 19:02:19 +0800 Message-ID: <1650020543-24908-3-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Usually, filesystem will use a function named as fs_init_acl function that belong to acl.c and this function is externed in acl.h by using CONFIG_FS_POSIX_ACL. If filesystem disable this switch, we should not call xfs_set_acl also not call posix_acl_create/posix_acl_release because it is useless(We have do umask strip in vfs). Signed-off-by: Yang Xu --- fs/xfs/xfs_iops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index b34e8e4344a8..9487e68bdd3d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -146,10 +146,12 @@ xfs_create_need_xattr( struct posix_acl *default_acl, struct posix_acl *acl) { +#ifdef CONFIG_XFS_POSIX_ACL if (acl) return true; if (default_acl) return true; +#endif #if IS_ENABLED(CONFIG_SECURITY) if (dir->i_sb->s_security) return true; @@ -184,9 +186,11 @@ xfs_generic_create( rdev = 0; } +#ifdef CONFIG_XFS_POSIX_ACL error = posix_acl_create(dir, &mode, &default_acl, &acl); if (error) return error; +#endif /* Verify mode is valid also for tmpfile case */ error = xfs_dentry_mode_to_name(&name, dentry, mode); @@ -241,8 +245,10 @@ xfs_generic_create( xfs_finish_inode_setup(ip); out_free_acl: +#ifdef CONFIG_XFS_POSIX_ACL posix_acl_release(default_acl); posix_acl_release(acl); +#endif return error; out_cleanup_inode: From patchwork Fri Apr 15 11:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 561950 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 D3C6AC4332F for ; Fri, 15 Apr 2022 10:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352102AbiDOKFt (ORCPT ); Fri, 15 Apr 2022 06:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352091AbiDOKFq (ORCPT ); Fri, 15 Apr 2022 06:05:46 -0400 Received: from mail1.bemta32.messagelabs.com (mail1.bemta32.messagelabs.com [195.245.230.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 331F7BB0AA; Fri, 15 Apr 2022 03:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1650016996; i=@fujitsu.com; bh=umWvxw61hLIrbg/P5jUPIscneWN2fsBQmpr2GWuMT1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N9X5mnLhce+1t4S94dAZ23gA4neRsLoDqT9V4/dqE0sRcq8/eHi5rAcr/5ELDTNc6 tEYc5RwuuWPa8QbtTopuztzK6/zHn2Odf+CYNzzuBJN/jM8yvrdVTBva/eqCFbtxaC f+dEZVLXYEta9KFRIS84+DDgn/H0++ZIJMzbjv9B4UD9q+0loLgekmAqpJK88ZFML1 j2O0rimxUTCt4dDGYNqPyOfQZK/jOfXW9PAbSVmjk4TqFoiVJx6x/KiDs01jIMK8Qg Jvql/fFjm/QgsmrFTABbcWK10SojGQobVwryppeZIFrgrhbWi/qj/RGiLA057J0ZrN yBeehB+HU3Alg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRWlGSWpSXmKPExsViZ8MRovvYKTL J4GKDnsXrw58YLT7cnMRkseXYPUaLy0/4LH4uW8VusWfvSRaLCwdOs1rs+rOD3eL83+OsDpwe pxZJeGxa1cnm8XmTnMemJ2+ZAliiWDPzkvIrElgzHqx8zFbQy1Ex8dZstgbG32xdjFwcQgKvG SUeXj/GBOHsYZTY//EhSxcjJwebgKbEs84FzCC2iICLxMIJ6xlBipgFXjFKTN87A6xIWMBc4v Caf2A2i4CqxJ/jK9lAbF4BT4ndD2+wgtgSAgoSUx6+BxrEwcEp4CXx/2wtSFgIqGTqpMtQ5YI SJ2c+ARvDLCAhcfDFC2aIVkWJSx3fGCHsColZs9qYJjDyz0LSMgtJywJGplWMVklFmekZJbmJ mTm6hgYGuoaGprpA0tREL7FKN1EvtVS3PLW4RNdQL7G8WC+1uFivuDI3OSdFLy+1ZBMjMPhTi hlm7WCc1fdT7xCjJAeTkijvW9HIJCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvH/tgXKCRanpqR VpmTnASIRJS3DwKInwhloDpXmLCxJzizPTIVKnGBWlxHmFgfErJACSyCjNg2uDRf8lRlkpYV5 GBgYGIZ6C1KLczBJU+VeM4hyMSsK8xiBTeDLzSuCmA+MG6GYR3m+rQkEWlyQipKQamM6rKDAF hLh4M8/Lq7tfF5cns3GR0XXdNRomP15x7Jz69et2sXMmCtlpSo0/X63snpv2sbDF6On9fyLe0 7gfhpo9uio5wbT47PKvBfrV/37oz1n9nUO59Me1C3+kuZy620QXbE11LS4S3LAyL/zy4ZLuzE gLY6sbq3szlx/Nj/uwOC42M1CR64LlbJ+uh5Lvzog3Ku6d/KwwwXEJH9uS7qeyfGXfF/FnPdH j+1vqJXDpy2HGXftuS+RkPvN18dvbwtwT8MLGrFP86rsjR7L37tNUij5/44ipbZb2Zn+Lp2cc Pmc6HfV/xnbb3Frg75SkmfXmWgXGofwSGxmTrDbyFGTo5ixX+bUsq4Bz6dGvSizFGYmGWsxFx YkAQ7iXxHkDAAA= X-Env-Sender: xuyang2018.jy@fujitsu.com X-Msg-Ref: server-12.tower-587.messagelabs.com!1650016995!55935!1 X-Originating-IP: [62.60.8.84] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.85.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16905 invoked from network); 15 Apr 2022 10:03:15 -0000 Received: from unknown (HELO mailhost3.uk.fujitsu.com) (62.60.8.84) by server-12.tower-587.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Apr 2022 10:03:15 -0000 Received: from R01UKEXCASM126.r01.fujitsu.local ([10.183.43.178]) by mailhost3.uk.fujitsu.com (8.14.5/8.14.5) with ESMTP id 23FA3Fer019126 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 15 Apr 2022 11:03:15 +0100 Received: from localhost.localdomain (10.167.220.84) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 15 Apr 2022 11:03:10 +0100 From: Yang Xu To: , , CC: , , , , , , Yang Xu Subject: [PATCH v3 5/7] fs: Add new helper prepare_mode Date: Fri, 15 Apr 2022 19:02:21 +0800 Message-ID: <1650020543-24908-5-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org As Christian Brauner suggested, add a new helper calls inode_sgid_strip() and does the umask stripping as well and then call it in all these places. This api is introduced to support strip file's S_ISGID mode on vfs instead of on underlying filesystem. Suggested-by: Christian Brauner (Microsoft) Signed-off-by: Yang Xu --- include/linux/fs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 4a617aaab6f6..8c2f4cde974b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3458,6 +3458,15 @@ static inline bool dir_relax_shared(struct inode *inode) return !IS_DEADDIR(inode); } +static inline void prepare_mode(struct user_namespace *mnt_userns, + const struct inode *dir, umode_t *mode) +{ + inode_sgid_strip(mnt_userns, dir, mode); + + if (!IS_POSIXACL(dir)) + *mode &= ~current_umask(); +} + extern bool path_noexec(const struct path *path); extern void inode_nohighmem(struct inode *inode); From patchwork Fri Apr 15 11:02:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 561949 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 A86C6C433F5 for ; Fri, 15 Apr 2022 10:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352116AbiDOKHV (ORCPT ); Fri, 15 Apr 2022 06:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235926AbiDOKHS (ORCPT ); Fri, 15 Apr 2022 06:07:18 -0400 Received: from mail1.bemta36.messagelabs.com (mail1.bemta36.messagelabs.com [85.158.142.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E5B9FCB; Fri, 15 Apr 2022 03:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1650017083; i=@fujitsu.com; bh=2BEBt+KtqG1w23kjA03oL0N4j7CMYSd/9MBWpZADdAw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bW3TaDdV0Lz8DzgF0QxGg1uM2d1wZG8DuvE3UVTnNFOCzRUeV0eDd502znGoRedpd TxpYEclkcTimdkKEyO8CddXIKpHyB23+e0JLMbm9E/ft4soDZEtXQclB4/9k5XwVWw RqgpAPLfEEbzR72sWCWxUQ3stdFeZEnfUtESjkIVT7fl/ht9rGDo+pOGWdP7Pf0deU GnZWBYVOoy7c7IfbiqCXxKd2xhDHk6n0DIxQ3bhjQG9mkq+HM3hT+ScW24Kmz2JgxT JoISNSb6q6ZWt8kLW1axzLUNJB2S476DYA/+5BuMCXRuRiFYgpd2ttTqfrcumKRInk rXAiUQm3QsEqQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgleJIrShJLcpLzFFi42Kxs+GYpGvtHJl k8KaT0+L14U+MFh9uTmKy2HLsHqPF5Sd8Fj+XrWK32LP3JIvFhQOnWS12/dnBbnH+73FWB06P U4skPDat6mTz+LxJzmPTk7dMASxRrJl5SfkVCawZpzpPshX0slU8PHCRpYGxl7WLkYtDSGALo 8Sh+3sZIZwFTBLfPl1m6WLkBHL2MEp8ORIJYrMJaEo861zADGKLCLhILJywHqyBWeAKo8T19j lgCWGBYIkp+1vBmlkEVCV6dkwDinNw8Ap4SrzrFAQJSwgoSEx5+B4szCngJfH/bC3EKk+JqZM us4HYvAKCEidnPgGbwiwgIXHwxQtmiFZFiUsd3xgh7AqJWbPamCBsNYmr5zYxT2AUnIWkfRaS 9gWMTKsYbZOKMtMzSnITM3N0DQ0MdA0NTXXNLHWNjfUSq3QT9VJLdZNT80qKEoGyeonlxXqpx cV6xZW5yTkpenmpJZsYgRGTUuyquIPxWt9PvUOMkhxMSqK8b0Ujk4T4kvJTKjMSizPii0pzUo sPMcpwcChJ8P61B8oJFqWmp1akZeYAoxcmLcHBoyTCG2oNlOYtLkjMLc5Mh0idYlSUEucVdgJ KCIAkMkrz4NpgCeMSo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeY5ApPJl5JXDTXwEtZgJa /G1VKMjikkSElFQDk6KRdNR0Ld5fVzKaPO8Xm3fILncRsAuPy9j9xljL8cJ+7d2qLy3+vt2c8 rC0ReTm/UcVUjdfve4UMra+HCDwfZrrp1+f9gs45K/+trPFw9Wt2PPa2TYFx+XP776WmviltK xa0PBvVtqV77MvSl5tWia85ryOWcHFAxsZJlqJfSj6Ifyg0mQ/c8WdinUVcVtneOR1Ni1wdDp z6p+WzPJlr2SDk1pFDCsP5n8LlN47+/Fx3/e7bI7WJbPNvy9zTevTVsXGlQ+vnDSe8HbSbWG5 /P4fHmmPJm14wexfeiGvMfTfbQmjH1rli4OLs5peSly4Fnr4k158ZM9XU0v/VTnzWG9tfuPra HFIPH9y7knWE0osxRmJhlrMRcWJAPSKhAmTAwAA X-Env-Sender: xuyang2018.jy@fujitsu.com X-Msg-Ref: server-12.tower-528.messagelabs.com!1650017082!67435!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.85.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4420 invoked from network); 15 Apr 2022 10:04:43 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-12.tower-528.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Apr 2022 10:04:43 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 9E27110047A; Fri, 15 Apr 2022 11:04:42 +0100 (BST) Received: from R01UKEXCASM126.r01.fujitsu.local (unknown [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id 919E2100467; Fri, 15 Apr 2022 11:04:42 +0100 (BST) Received: from localhost.localdomain (10.167.220.84) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 15 Apr 2022 11:04:18 +0100 From: Yang Xu To: , , CC: , , , , , , Yang Xu Subject: [PATCH v3 7/7] ceph: Remove S_ISGID clear code in ceph_finish_async_create Date: Fri, 15 Apr 2022 19:02:23 +0800 Message-ID: <1650020543-24908-7-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1650020543-24908-1-git-send-email-xuyang2018.jy@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Since vfs has stripped S_ISGID, we don't need this code any more. Signed-off-by: Yang Xu --- fs/ceph/file.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 6c9e837aa1d3..8e3b99853333 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -651,10 +651,6 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, /* Directories always inherit the setgid bit. */ if (S_ISDIR(mode)) mode |= S_ISGID; - else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) && - !in_group_p(dir->i_gid) && - !capable_wrt_inode_uidgid(&init_user_ns, dir, CAP_FSETID)) - mode &= ~S_ISGID; } else { in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid())); }