Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1533537rwe; Sat, 27 Aug 2022 10:07:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR59DjnjP7vAb8gGtOGz7nwjhZvOvPa+5UTX2r3NwOvatL3FFhb5+e++dl4yeBEZA+REC1g/ X-Received: by 2002:a05:6402:4311:b0:447:9fb:b710 with SMTP id m17-20020a056402431100b0044709fbb710mr10392514edc.272.1661620068951; Sat, 27 Aug 2022 10:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661620068; cv=none; d=google.com; s=arc-20160816; b=QI1qdz5uZvPWeBxMexQ51iuiBiLwW3xyXIs4QPduQJUtEm7PmvLfOtvLOHPorZCzTO ZL/USDzSmouJpH3SHXbzDUX+Xleurb1PnrmTdm6IYT2LvTDXcAtO1J2ij9KVnxBJIACb 7s+9AQeu+TLvKazVR/0wkCbXH1PFH8vd8H5mEynN3ddGjHxZOBUHxtgnDqXnVSpBJgLg b9wvy5PZPUyHL2r3vzMsRoMXln4EMtuS4+uyZ6tCs/tgjNDendJDxQzufcQcD9dXIgQD BsWo6XoEftJQBLBKnewny5G+9MzboaccgEB1kUgrBhQzHFVwoRf7W2ogoLnGFVBrMS+M ocDw== 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=R8/bF5KHLjTt9GLEnmNnJrfmlxn+HrK5JbBv33yEUFg=; b=XHO53c/95Q7yGVa7q78rBA1HqwXXy/HDBS+9HzH13NmJw/Us4KxI5FrZltxiqQp6Ai Qj8aP1qfZzG7+WoSTAlJGo2rNzUQ8ld9dgRWI6F6coddQID7kRXUwDehxfG2wSpAarVI H2wJnqybyvMGJ82NIKJ+XSCoV7G9dMc9R7ubGOG5FFZHk+E87gb4nJRzqwLI5CDl/L3D 6co1kHfTPnaB5Wwbr3DdiKW9RgdQK97hN7/soklKnensxHMLgckIgZyshGzbiuurX4ng Ay6RBBSeIc4DJII375q4ItNliKM5n+T4dqckkwQEJ/dNvpIIokiENVOTbyLQkFA4ybTw Re7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W4DsfOUo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt44-20020a1709072dac00b00730412fe4d5si4325091ejc.740.2022.08.27.10.07.22; Sat, 27 Aug 2022 10:07:48 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W4DsfOUo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233905AbiH0Q6F (ORCPT + 99 others); Sat, 27 Aug 2022 12:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233884AbiH0Q6D (ORCPT ); Sat, 27 Aug 2022 12:58:03 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C0D59250; Sat, 27 Aug 2022 09:58:01 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id b5so5242273wrr.5; Sat, 27 Aug 2022 09:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc; bh=R8/bF5KHLjTt9GLEnmNnJrfmlxn+HrK5JbBv33yEUFg=; b=W4DsfOUo7kKFGo7dVPXf0A9z/bKIKPbGdjgVun0Q2pPxb+6oybEGLtuAk5nqHI8Uql xTBMozGCA9RRFp4mcWnafvbNyeGx1Q92B142WdY3yImSz9TKkdl7O08y7irg/aLAubrm lcfvbV8UIJ76iHZRoo557DhYHLf5YQxzIdUl+oWyL5xUk+zWp2aIcWvjwcIV208biuaW QQVdQwaNRRkiUndjx7EB6rsyCMF92jmD/7nO2WtEA8wF4C31swCdsshyo1DLiI53VX3t rzDGhqO1l8A4csN92AcBM0+dhs0/mxvH0HOumnGOCl1S2xQyRMU0ZhSVUw0SwTZAMrIW EVAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc; bh=R8/bF5KHLjTt9GLEnmNnJrfmlxn+HrK5JbBv33yEUFg=; b=vtqzz7lCaxM2zcXy1erSPyXtTQpspd7GAQo906mGepeI0T7WiFW4XGz2Z70azrl6Xp 8993V4YyBaVe/OcS4BWXbnVcdV/ZfIYZjXl+K4iRtstFomBeohwhjZfN6yqdZVwTA40L dynzb6j5q0XWl6wTSukludSdNb8mXBPbpGLxNCwEsgmELsklUBO5c1owoCx2BXttSh6M R8xgGOKkFCbIY56a+EyURftIM5H21h1n7exD2aFqHPTNS7giUtgFF7mdYnHq7i7QPLrW o68gu+ONtID5O/UROMiAhs4iwV8xs/VUseo0yFWe3KlK2ZcCbiKMGknW1lVPSUwA1zlp ZJeQ== X-Gm-Message-State: ACgBeo3U39nZKgAhLsY/BifUIzAlitAPmYegQyX98gxGIHFJx0Dwm158 AlNPsVtAxvWmEGGRw37uUOYMsIv6+iE= X-Received: by 2002:adf:e0c3:0:b0:226:d598:85ee with SMTP id m3-20020adfe0c3000000b00226d59885eemr405190wri.589.1661619479950; Sat, 27 Aug 2022 09:57:59 -0700 (PDT) Received: from nuc ([2a02:168:633b:1:1e69:7aff:fe05:97e6]) by smtp.gmail.com with ESMTPSA id x3-20020a05600c420300b003a5bd9448e5sm3111585wmh.28.2022.08.27.09.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 09:57:59 -0700 (PDT) Date: Sat, 27 Aug 2022 18:57:57 +0200 From: =?iso-8859-1?Q?G=FCnther?= Noack To: xiujianfeng Cc: mic@digikod.net, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, shuah@kernel.org, corbet@lwn.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH -next 3/5] landlock/selftests: add selftests for chmod and chown Message-ID: References: <20220822114701.26975-1-xiujianfeng@huawei.com> <20220822114701.26975-4-xiujianfeng@huawei.com> <64b93d8e-f2b0-31c8-0736-3194053de687@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <64b93d8e-f2b0-31c8-0736-3194053de687@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 On Sat, Aug 27, 2022 at 07:14:30PM +0800, xiujianfeng wrote: > Hi, > > 在 2022/8/23 3:26, Günther Noack 写道: > > On Mon, Aug 22, 2022 at 07:46:59PM +0800, Xiu Jianfeng wrote: > > > +TEST_F_FORK(layout1, unhandled_chmod) > > > +{ > > > + const struct rule rules[] = { > > > + { > > > + .path = file2_s3d1, > > > + .access = LANDLOCK_ACCESS_FS_READ_FILE | > > > + LANDLOCK_ACCESS_FS_WRITE_FILE, > > > + }, > > > + { > > > + .path = file3_s3d1, > > > + .access = LANDLOCK_ACCESS_FS_READ_FILE | > > > + LANDLOCK_ACCESS_FS_WRITE_FILE, > > > + }, > > > + {}, > > > + }; > > > + const int ruleset_fd = > > > + create_ruleset(_metadata, ACCESS_RW, rules); > > > + > > > + ASSERT_LE(0, ruleset_fd); > > > + enforce_ruleset(_metadata, ruleset_fd); > > > + ASSERT_EQ(0, close(ruleset_fd)); > > > + > > > + ASSERT_EQ(0, test_chmod(file2_s3d1)); > > > + ASSERT_EQ(0, test_fchmod(file2_s3d1)); > > > + ASSERT_EQ(0, test_chmod(file3_s3d1)); > > > + ASSERT_EQ(0, test_chmod(dir_s3d1)); > > > +} > > > > I missed it in the previous mail: > > > > There are also the chown variants lchown() and fchownat(), as well as > > the chmod variant fchmodat(), which might be interesting to test, > > especially the symlink scenarios. > > > > fchmodat() has a AT_SYMLINK_NOFOLLOW flag which does the chmod > > equivalent to lchown(). > > > > man fchmodat shows as follows: > ... > AT_SYMLINK_NOFOLLOW > If pathname is a symbolic link, do not dereference it: instead operate on > the link itself. This flag is not currently implemented. > ... > > so I suppose this can not be test. Please correct me if I am wrong. Good point - I didn't realize that AT_SYMLINK_NOFOLLOW was not implemented for fchmodat. In that case, this only applies to lchown. —Günther --