All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: sashiko-reviews@lists.linux.dev
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 6/8] selftests/landlock: Add capability restriction tests
Date: Tue, 6 Oct 2026 11:57:10 +0200	[thread overview]
Message-ID: <20261006.Aiwohkeel3ee@digikod.net> (raw)
In-Reply-To: <20261002125356.4C1321F000FF@smtp.kernel.org>

On Fri, Oct 02, 2026 at 12:53:55PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] selftests/landlock: host hostname modification in cap_without_nnp test failure
> --
> 
> commit 359c59ecc043d1cac20779ee8cc6bc19e3b8e705
> Author: Mickaël Salaün <mic@digikod.net>
> selftests/landlock: Add capability restriction tests
> 
> This commit adds tests to exercise capability restrictions enforced by
> Landlock. It covers various standard capability evaluations, stacking
> combinations, and non-standard contexts such as enforcing a domain
> without no_new_privs.
> 
> > diff --git a/tools/testing/selftests/landlock/cap_test.c b/tools/testing/selftests/landlock/cap_test.c
> > new file mode 100644
> > index 0000000000000..8673934aac11e
> > --- /dev/null
> > +++ b/tools/testing/selftests/landlock/cap_test.c
> [ ... ]
> > +TEST(cap_without_nnp)
> > +{
> > +	int ruleset_fd;
> > +
> > +	disable_caps(_metadata);
> > +
> > +	ruleset_fd = create_cap_ruleset();
> > +	ASSERT_LE(0, ruleset_fd);
> > +
> > +	/* Allow CAP_SYS_CHROOT but not CAP_SYS_ADMIN. */
> > +	ASSERT_EQ(0, add_cap_rule(ruleset_fd, CAP_SYS_CHROOT));
> > +
> > +	/*
> > +	 * Enforce WITHOUT NNP: landlock_restrict_self() succeeds when the
> > +	 * caller has CAP_SYS_ADMIN (checked before the new domain takes
> > +	 * effect).
> > +	 */
> > +	set_cap(_metadata, CAP_SYS_ADMIN);
> > +	ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0));
> > +	EXPECT_EQ(0, close(ruleset_fd));
> > +
> > +	/*
> > +	 * CAP_SYS_ADMIN is still in effective set but Landlock denies it:
> > +	 * cap_capable() returns 0, then hook_capable() returns -EPERM.
> > +	 */
> > +	EXPECT_EQ(-1, sethostname("test", 4));
> 
> [Severity: Medium]
> Will this modify the host system's hostname if the test fails?
> 
> The cap_without_nnp test does not appear to isolate its UTS namespace via
> unshare(CLONE_NEWUTS) before verifying the sethostname() restriction. If the
> Landlock enforcement does not block the operation during a failing test run,
> could the sethostname("test", 4) call succeed and unexpectedly change the
> test machine's global hostname?

I'll fix these issues.

> 
> > +	EXPECT_EQ(EPERM, errno);
> > +
> > +	/* CAP_SYS_CHROOT is allowed by the rule. */
> > +	set_cap(_metadata, CAP_SYS_CHROOT);
> > +	EXPECT_EQ(0, chroot("/"));
> > +}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20261002124409.1277970-1-mic@digikod.net?part=6
> 

  reply	other threads:[~2026-10-06  9:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 12:43 [PATCH v4 0/8] Landlock: Namespace and capability control Mickaël Salaün
2026-10-02 12:43 ` [PATCH v4 1/8] landlock: Rename quiet_masks to quiet_access Mickaël Salaün
2026-10-02 12:50   ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 2/8] landlock: Wrap per-layer access masks in struct layer_config Mickaël Salaün
2026-10-02 12:49   ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 3/8] landlock: Enforce namespace use restrictions Mickaël Salaün
2026-10-02 12:52   ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 4/8] landlock: Enforce capability restrictions Mickaël Salaün
2026-10-02 12:53   ` sashiko-bot
2026-10-02 12:43 ` [PATCH v4 5/8] selftests/landlock: Add namespace restriction tests Mickaël Salaün
2026-10-02 12:56   ` sashiko-bot
2026-10-06  9:56     ` Mickaël Salaün
2026-10-02 12:43 ` [PATCH v4 6/8] selftests/landlock: Add capability " Mickaël Salaün
2026-10-02 12:53   ` sashiko-bot
2026-10-06  9:57     ` Mickaël Salaün [this message]
2026-10-02 12:44 ` [PATCH v4 7/8] samples/landlock: Add capability and namespace restriction support Mickaël Salaün
2026-10-02 12:53   ` sashiko-bot
2026-10-06  9:57     ` Mickaël Salaün
2026-10-02 12:44 ` [PATCH v4 8/8] landlock: Add documentation for capability and namespace restrictions Mickaël Salaün
2026-10-02 12:59   ` sashiko-bot

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=20261006.Aiwohkeel3ee@digikod.net \
    --to=mic@digikod.net \
    --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.