Linux Security Modules development
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Tingmao Wang <m@maowtm.org>
Cc: "Günther Noack" <gnoack3000@gmail.com>,
	"Justin Suess" <utilityemal77@gmail.com>,
	"Jan Kara" <jack@suse.cz>, "Abhinav Saxena" <xandfury@gmail.com>,
	linux-security-module@vger.kernel.org
Subject: Re: [PATCH v10 9/9] selftests/landlock: Add tests for invalid use of quiet flag
Date: Tue, 9 Jun 2026 00:41:57 +0200	[thread overview]
Message-ID: <20260609.Quah2aegeiMu@digikod.net> (raw)
In-Reply-To: <99587e6f737a425d18fda31649edf304f74f3567.1780272022.git.m@maowtm.org>

On Mon, Jun 01, 2026 at 01:00:43AM +0100, Tingmao Wang wrote:
> Make sure that these calls return EINVAL.
> 
> Signed-off-by: Tingmao Wang <m@maowtm.org>
> ---
> 
> Changes in v4:
> - New patch
> 
>  tools/testing/selftests/landlock/base_test.c | 57 ++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
> index 84e91fcaa1b2..af9ad822a444 100644
> --- a/tools/testing/selftests/landlock/base_test.c
> +++ b/tools/testing/selftests/landlock/base_test.c
> @@ -526,4 +526,61 @@ TEST(cred_transfer)
>  	EXPECT_EQ(EACCES, errno);
>  }
>  
> +TEST(useless_quiet_rule)
> +{
> +	struct landlock_ruleset_attr ruleset_attr = {
> +		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_DIR,
> +		.quiet_access_fs = 0,

The other .quiet_* fields should also be tested.

> +	};
> +	struct landlock_path_beneath_attr path_beneath_attr = {
> +		.allowed_access = LANDLOCK_ACCESS_FS_READ_DIR,
> +	};
> +	int ruleset_fd, root_fd;
> +
> +	drop_caps(_metadata);
> +	ruleset_fd =
> +		landlock_create_ruleset(&ruleset_attr, sizeof(ruleset_attr), 0);
> +	ASSERT_LE(0, ruleset_fd);
> +
> +	root_fd = open("/", O_PATH | O_CLOEXEC);
> +	ASSERT_LE(0, root_fd);
> +	path_beneath_attr.parent_fd = root_fd;
> +	ASSERT_EQ(-1, landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,
> +					&path_beneath_attr,
> +					LANDLOCK_ADD_RULE_QUIET));
> +	ASSERT_EQ(EINVAL, errno);
> +
> +	/* Check that the rule had not been added. */
> +	ASSERT_EQ(0, close(root_fd));
> +	enforce_ruleset(_metadata, ruleset_fd);
> +	ASSERT_EQ(0, close(ruleset_fd));
> +
> +	ASSERT_EQ(-1, open("/", O_RDONLY | O_DIRECTORY | O_CLOEXEC));
> +	ASSERT_EQ(EACCES, errno);
> +}
> +
> +TEST(invalid_quiet_bits_1)
> +{
> +	struct landlock_ruleset_attr ruleset_attr = {
> +		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_DIR,
> +		.quiet_access_fs = LANDLOCK_ACCESS_FS_WRITE_FILE,

ditto

> +	};
> +
> +	ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr,
> +					      sizeof(ruleset_attr), 0));
> +	ASSERT_EQ(EINVAL, errno);
> +}
> +
> +TEST(invalid_quiet_bits_2)
> +{
> +	struct landlock_ruleset_attr ruleset_attr = {
> +		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_DIR,
> +		.quiet_access_fs = 1ULL << 63,

ditto

> +	};
> +
> +	ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr,
> +					      sizeof(ruleset_attr), 0));
> +	ASSERT_EQ(EINVAL, errno);
> +}
> +
>  TEST_HARNESS_MAIN
> -- 
> 2.54.0
> 

      reply	other threads:[~2026-06-08 22:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  0:00 [PATCH v10 0/9] Implement LANDLOCK_ADD_RULE_QUIET Tingmao Wang
2026-06-01  0:00 ` [PATCH v10 1/9] landlock: Add a place for flags to layer rules Tingmao Wang
2026-06-08 22:40   ` Mickaël Salaün
2026-06-01  0:00 ` [PATCH v10 2/9] landlock: Add API support and docs for the quiet flags Tingmao Wang
2026-06-08 22:41   ` Mickaël Salaün
2026-06-01  0:00 ` [PATCH v10 3/9] landlock: Suppress logging when quiet flag is present Tingmao Wang
2026-06-08 22:41   ` Mickaël Salaün
2026-06-01  0:00 ` [PATCH v10 4/9] samples/landlock: Add quiet flag support to sandboxer Tingmao Wang
2026-06-08 22:41   ` Mickaël Salaün
2026-06-01  0:00 ` [PATCH v10 5/9] selftests/landlock: Replace hard-coded 16 with a constant Tingmao Wang
2026-06-01  0:00 ` [PATCH v10 6/9] selftests/landlock: add tests for quiet flag with fs rules Tingmao Wang
2026-06-05 19:04   ` Justin Suess
2026-06-08  1:31     ` Tingmao Wang
2026-06-01  0:00 ` [PATCH v10 7/9] selftests/landlock: add tests for quiet flag with net rules Tingmao Wang
2026-06-01  0:00 ` [PATCH v10 8/9] selftests/landlock: Add tests for quiet flag with scope Tingmao Wang
2026-06-01  0:00 ` [PATCH v10 9/9] selftests/landlock: Add tests for invalid use of quiet flag Tingmao Wang
2026-06-08 22:41   ` Mickaël Salaün [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260609.Quah2aegeiMu@digikod.net \
    --to=mic@digikod.net \
    --cc=gnoack3000@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-security-module@vger.kernel.org \
    --cc=m@maowtm.org \
    --cc=utilityemal77@gmail.com \
    --cc=xandfury@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox