Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1252524rwe; Sat, 27 Aug 2022 04:18:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Mbt/5dE3+/axphbFdGjdL6cmV5CXEhHEYVJCy7Ol3Nzn0fkt16dVezPaQeZvJRFfWk+h4 X-Received: by 2002:a17:90a:744c:b0:1fa:c029:7a24 with SMTP id o12-20020a17090a744c00b001fac0297a24mr8754555pjk.54.1661599127081; Sat, 27 Aug 2022 04:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661599127; cv=none; d=google.com; s=arc-20160816; b=QN3ruzuD+vogBojWTr41SoPCWRMKq/6h/5cbq+O+xLhNBCIXVbTEtPJnFGnkNZoIHG A2HIAVhkyQrgMJbXLZF+leHmwvr/b88Bk6xbukbIfmNQ8xcldsHnW8QLIEsk40D1bXOL H7d4WBQLsf+47jSPUqNF7hfYccH3hwSAberHaHYC2zmeBRtxW9O6PQPIg3DLg5gsg7yK SD/7oetBzz+GUNsXJg3FuR/alfybBJMyYapxdSUhS9xWsZFa4JA9zuR3GCkzRR2DJHy6 j8XtprRiVE/1H2KJ+ssDi2SZZStvxkTwUkm9QfTccmvDN0ACLZaFkwZrPFpGOi0U6q69 gTMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=LWtXHjzVK1kPjIW8gVuhR5bF7sC1cLntAsTTJSTEgdY=; b=lmU1yWgMRL9peqTKNI2lvjD0K8X+0gvVzv6i6nqqg3nOhbBy/YuY2F+XqqDpj5n0gF zoPHzdtEtkVHAS2rGeo2YD0ROZ8e6voQeJD2nEOHhHbd8XPPbmjdB49BG0PT93GmQAkb kSomcav2sKKyDSvg3nZsEpfIfbmGdd5RqUDelNZ1CH3iEQceiy/jgoKvK+d/p0KyocVG nFIBHDfE4NKPLENEwdtBo68zHKbtYKzpj8zYJzrS1apcvmoDNJdTIZA706sIncZBvxHd mVvGAFzDCUPsgxh5Bkf6s86tZvZIT8wTf68DFkeelxrggfN2YP6YRdsoybL7Palc3xa7 9fVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a63040d000000b00429ea6e9438si4074437pge.224.2022.08.27.04.18.36; Sat, 27 Aug 2022 04:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344609AbiH0LQQ (ORCPT + 99 others); Sat, 27 Aug 2022 07:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245071AbiH0LQB (ORCPT ); Sat, 27 Aug 2022 07:16:01 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2391222BD5; Sat, 27 Aug 2022 04:15:56 -0700 (PDT) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MFDZC5GRdzlWWl; Sat, 27 Aug 2022 19:12:35 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 19:15:54 +0800 From: Xiu Jianfeng To: , , , , , CC: , , , Subject: [PATCH -next v2 5/6] landlock/samples: add chmod and chown support Date: Sat, 27 Aug 2022 19:12:14 +0800 Message-ID: <20220827111215.131442-6-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220827111215.131442-1-xiujianfeng@huawei.com> References: <20220827111215.131442-1-xiujianfeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org update landlock sample to support the new flags LANDLOCK_ACCESS_FS_{CHMOD, CHGRP} Signed-off-by: Xiu Jianfeng --- samples/landlock/sandboxer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c index 771b6b10d519..639ec39ebd0a 100644 --- a/samples/landlock/sandboxer.c +++ b/samples/landlock/sandboxer.c @@ -77,7 +77,9 @@ static int parse_path(char *env_path, const char ***const path_list) LANDLOCK_ACCESS_FS_EXECUTE | \ LANDLOCK_ACCESS_FS_WRITE_FILE | \ LANDLOCK_ACCESS_FS_READ_FILE | \ - LANDLOCK_ACCESS_FS_TRUNCATE) + LANDLOCK_ACCESS_FS_TRUNCATE | \ + LANDLOCK_ACCESS_FS_CHMOD | \ + LANDLOCK_ACCESS_FS_CHGRP) /* clang-format on */ @@ -162,7 +164,9 @@ static int populate_ruleset(const char *const env_var, const int ruleset_fd, LANDLOCK_ACCESS_FS_MAKE_BLOCK | \ LANDLOCK_ACCESS_FS_MAKE_SYM | \ LANDLOCK_ACCESS_FS_REFER | \ - LANDLOCK_ACCESS_FS_TRUNCATE) + LANDLOCK_ACCESS_FS_TRUNCATE | \ + LANDLOCK_ACCESS_FS_CHMOD | \ + LANDLOCK_ACCESS_FS_CHGRP) /* clang-format on */ @@ -233,6 +237,11 @@ int main(const int argc, char *const argv[], char *const *const envp) case 2: /* Removes LANDLOCK_ACCESS_FS_TRUNCATE for ABI < 3 */ ruleset_attr.handled_access_fs &= ~LANDLOCK_ACCESS_FS_TRUNCATE; + __attribute__((fallthrough)); + case 3: + /* Removes LANDLOCK_ACCESS_FS_{CHMOD, CHGRP} for ABI < 4 */ + ruleset_attr.handled_access_fs &= ~(LANDLOCK_ACCESS_FS_CHMOD | + LANDLOCK_ACCESS_FS_CHGRP); } access_fs_ro &= ruleset_attr.handled_access_fs; access_fs_rw &= ruleset_attr.handled_access_fs; -- 2.17.1