All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/2] landlock: Add a test for REFER layer composition with network layer
Date: Thu, 12 Nov 2026 05:42:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-210473@kernel.org> (raw)
In-Reply-To: <20261112052713.859515-2-mangosteen922@126.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] landlock: use of handle instead of real full name in
  Signed-off-by
- [Low] selftests/landlock: redundant dir_s1d3 rule in
  refer_with_net_layer()
--

commit a26cce886a00516c15353a37b118df17895f1736
Author: pandaWall <mangosteen922@126.com>

> landlock: Add a test for REFER layer composition with network layer
>
> Check that stacking a network-only ruleset (i.e. a layer handling no
> filesystem access right) on top of a filesystem ruleset still allows
> different-parent renames and exchanges allowed by the filesystem layer.
> Before the fix, such a layer implicitly handled
> LANDLOCK_ACCESS_FS_REFER and denied these operations with EXDEV.
>
> Both parent directories get MAKE_REG because each is the destination
> parent of one rename direction (and of the exchange), as
> current_check_refer_path() requires the moved file type's access right
> on both parents.
>
> Signed-off-by: pandaWall <mangosteen922@126.com>

[Severity: High]
Per Documentation/process/submitting-patches.rst (Developer's Certificate
of Origin), the Author header and Signed-off-by trailer must use a real
full human name rather than a single-word handle ("pandaWall").

> diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
> index f725882fa4a78..cf11281639c67 100644
> --- a/tools/testing/selftests/landlock/fs_test.c
> +++ b/tools/testing/selftests/landlock/fs_test.c
> @@ -2570,6 +2570,49 @@ const struct rule layer_dir_s2d1_execute[] = {
>  	{},
>  };
>  
> +/*
> + * Tests that a layer not handling filesystem access rights does not
> + * implicitly handle LANDLOCK_ACCESS_FS_REFER, which would otherwise deny
> + * different-parent renames and links stacked on top of a filesystem ruleset.
> + */
> +TEST_F_FORK(layout1, refer_with_net_layer)
> +{
> +	const struct rule layer_fs[] = {
> +		{
> +			.path = dir_s1d2,
> +			.access = LANDLOCK_ACCESS_FS_REFER |
> +				  LANDLOCK_ACCESS_FS_MAKE_REG,
> +		},
> +		{
> +			.path = dir_s1d3,
> +			.access = LANDLOCK_ACCESS_FS_MAKE_REG,
> +		},
> +		{},
> +	};
> +	const struct landlock_ruleset_attr ruleset_net = {
> +		.handled_access_net = LANDLOCK_ACCESS_NET_BIND_TCP,
> +	};
> +
> +	/*
> +	 * layer_fs alone: different-parent renames are allowed.  Both
> +	 * parent directories need MAKE_REG because each is the destination
> +	 * of one rename direction, and the destination parent of an
> +	 * exchange.
> +	 */
> +	enforce_fs(_metadata, LANDLOCK_ACCESS_FS_REFER |
> +				      LANDLOCK_ACCESS_FS_MAKE_REG,
> +		   layer_fs);

[Severity: Low]
Is the second rule in layer_fs[] on dir_s1d3 redundant?

In layout1, dir_s1d3 (TMP_DIR/s1d1/s1d2/s1d3) is a subdirectory of
dir_s1d2, so the first rule on dir_s1d2 already grants both
LANDLOCK_ACCESS_FS_REFER and LANDLOCK_ACCESS_FS_MAKE_REG to dir_s1d3.
Moreover, current_check_refer_path() requires LANDLOCK_ACCESS_FS_REFER on
both parent directories, so if dir_s1d3 did not inherit from dir_s1d2, the
second rule omitting LANDLOCK_ACCESS_FS_REFER would fail with EXDEV.

Because layer_fs[0] grants all handled filesystem rights in the domain on
dir_s1d2, collect_domain_accesses() in current_check_refer_path() also
returns true for both allow_parent1 and allow_parent2 and returns 0 early
before is_access_to_paths_allowed() checks LANDLOCK_ACCESS_FS_MAKE_REG.

Also, placing refer_with_net_layer here separates the
layer_dir_s1d1_refer, layer_dir_s1d1_execute, and layer_dir_s2d1_execute
rule definitions right above from the refer_denied_by_default1..4 tests
below that use them.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112052713.859515-1-mangosteen922@126.com?part=2

  reply	other threads:[~2026-11-12  5:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  2:55 [PATCH] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER pandaWall
2026-11-12  3:17 ` sashiko-bot
2026-11-12  5:27 ` [RFC PATCH v2 1/2] " pandaWall
2026-11-12  5:27   ` [RFC PATCH v2 2/2] landlock: Add a test for REFER layer composition with network layer pandaWall
2026-11-12  5:42     ` sashiko-bot [this message]
2026-11-12  5:36   ` [RFC PATCH v2 1/2] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER sashiko-bot
2026-11-12  6:52 ` [PATCH v3 " pandaWall
2026-11-12  6:52   ` [PATCH v3 2/2] landlock: Add a test for REFER layer composition with network layer pandaWall
2026-11-12  7:01     ` sashiko-bot
2026-11-12  7:04   ` [PATCH v3 1/2] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER sashiko-bot
2026-11-12  8:05 ` [PATCH] " Günther Noack
2026-11-12  8:33 ` Panda Chen

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=sashiko-outbox-210473@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.