From patchwork Thu Mar 31 09:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu (Fujitsu)" X-Patchwork-Id: 12796937 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 C2E39C433F5 for ; Thu, 31 Mar 2022 09:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232514AbiCaJaq (ORCPT ); Thu, 31 Mar 2022 05:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234159AbiCaJag (ORCPT ); Thu, 31 Mar 2022 05:30:36 -0400 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4390203A63; Thu, 31 Mar 2022 02:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1648718888; i=@fujitsu.com; bh=Ws9HhmWwP1sg/MJi353iJBVOr7t8+QgQ8rvucPbJZgE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dj1ROLcc6zW264WS/lCGttVW2wkgzvcUgWeG27Qq7o7TZYZXB86lxhiogVpvEQSH8 yp5m0esA8nHQ3WAbt6xRULH1qv3+eTfhwQYR7ptd9K5fo/GjWnxjS2E1jH9Da8tD+J i2eNo7FLBSe/34mwH0ytshQpqEUwnqIf/GXrbEUYSnthr4FU7xhh4rEAs+FKilBL4m PHFuMZeOXDeIdqLWZ4cZca62wWK39ltqnz+JJ4HVA3jsjJSfRjtP/HiEGpfb8b7rKi Ktmew8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H7hMOFlmZ5Fdqa2 xf/rwnyb3p6N4udf8GSqSvfdhVs3559LWaHr6yWwZ+nfk/OPBSuxFGckGmoxFxUnAgCbulbVd gMAAA== X-Env-Sender: xuyang2018.jy@fujitsu.com X-Msg-Ref: server-32.tower-565.messagelabs.com!1648718887!166249!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.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14123 invoked from network); 31 Mar 2022 09:28:08 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-32.tower-565.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 31 Mar 2022 09:28:08 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 4E26B1001AE; Thu, 31 Mar 2022 10:28:07 +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 BC0301001B1; Thu, 31 Mar 2022 10:28:06 +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; Thu, 31 Mar 2022 10:28:00 +0100 From: Yang Xu To: , , CC: , , Yang Xu Subject: [PATCH v1 2/2] idmapped-mounts: Add umask before test setgid_create Date: Thu, 31 Mar 2022 17:28:22 +0800 Message-ID: <1648718902-2319-2-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648718902-2319-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1648718902-2319-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: linux-fsdevel@vger.kernel.org Since stipping S_SIGID should check S_IXGRP, so umask it to check whether works well. Signed-off-by: Yang Xu Tested-by: Christian Brauner (Microsoft) Reviewed-by: Christian Brauner (Microsoft) --- If we enable acl on parent directory, then umask is useless, maybe we also add setfacl on parent directory because we may change the order about strip S_ISGID and posix_acl setup. Any idea? src/idmapped-mounts/idmapped-mounts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c index 1e2f3904..30292426 100644 --- a/src/idmapped-mounts/idmapped-mounts.c +++ b/src/idmapped-mounts/idmapped-mounts.c @@ -7843,6 +7843,7 @@ static int setgid_create(void) int file1_fd = -EBADF; pid_t pid; + umask(S_IXGRP); if (!caps_supported()) return 0; @@ -8040,6 +8041,8 @@ static int setgid_create_idmapped(void) }; pid_t pid; + umask(S_IXGRP); + if (!caps_supported()) return 0; @@ -8166,6 +8169,7 @@ static int setgid_create_idmapped_in_userns(void) }; pid_t pid; + umask(S_IXGRP); if (!caps_supported()) return 0;