MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Günther Noack" <gnoack3000@gmail.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH 2/6] selftests/landlock: Generalize net test helpers for multiple socket types
Date: Sun, 30 Aug 2026 20:28:50 +0000	[thread overview]
Message-ID: <20260830202851.57A281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830201650.67050-3-gnoack3000@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete refactoring: Several test fixtures retain hardcoded TCP/UDP checks instead of using the newly introduced generalized sandbox access helpers.
--

commit e9dd22f54640c7d9439f23efd0049803e698947e
Author: Günther Noack <gnoack3000@gmail.com>

selftests/landlock: Generalize net test helpers for multiple socket types

Create helper methods for determining the access rights to be tested
based on socket type (TCP or UDP). This makes it simpler to add more
socket types with similar bind(2) and connect(2) restrictions in the
future.

> diff --git a/tools/testing/selftests/landlock/net_test.c b/tools/testing/selftests/landlock/net_test.c
> index a18761e0fd82f..3a0482beca5f4 100644
> --- a/tools/testing/selftests/landlock/net_test.c
> +++ b/tools/testing/selftests/landlock/net_test.c
[ ... ]
> @@ -108,11 +108,41 @@ static bool prot_is_udp(const struct protocol_variant *const prot)
>  static bool is_restricted(const struct protocol_variant *const prot,
>  			  const enum sandbox_type sandbox)
>  {
> -	if (sandbox == TCP_SANDBOX)
> +	switch (sandbox) {
> +	case TCP_SANDBOX:
>  		return prot_is_tcp(prot);
> -	else if (sandbox == UDP_SANDBOX)
> +	case UDP_SANDBOX:
>  		return prot_is_udp(prot);
> -	return false;
> +	case NO_SANDBOX:
> +	default:
> +		return false;
> +	}
> +}
> +
> +static __u64 sandbox_bind_access(const enum sandbox_type sandbox)
> +{
> +	switch (sandbox) {
> +	case TCP_SANDBOX:
> +		return LANDLOCK_ACCESS_NET_BIND_TCP;
> +	case UDP_SANDBOX:
> +		return LANDLOCK_ACCESS_NET_BIND_UDP;
> +	case NO_SANDBOX:
> +	default:
> +		return 0;
> +	}
> +}
> +
> +static __u64 sandbox_connect_access(const enum sandbox_type sandbox)
> +{
> +	switch (sandbox) {
> +	case TCP_SANDBOX:
> +		return LANDLOCK_ACCESS_NET_CONNECT_TCP;
> +	case UDP_SANDBOX:
> +		return LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP;
> +	case NO_SANDBOX:
> +	default:
> +		return 0;
> +	}
>  }

[Severity: Medium]
Are there other test fixtures that also need to be updated to use these new
helpers?

It looks like TEST_F(ipv4, from_unix_to_inet), TEST_F(port_specific,
bind_connect_zero), and TEST_F(port_specific, bind_connect_1023) still use
the hardcoded TCP_SANDBOX and UDP_SANDBOX checks instead of the generalized
sandbox access helpers:

tools/testing/selftests/landlock/net_test.c:TEST_F(ipv4, from_unix_to_inet)() {
    ...
	if (variant->sandbox == TCP_SANDBOX ||
	    variant->sandbox == UDP_SANDBOX) {
		const __u64 access_rights =
			(variant->sandbox == TCP_SANDBOX ?
				 LANDLOCK_ACCESS_NET_BIND_TCP |
					 LANDLOCK_ACCESS_NET_CONNECT_TCP :
				 LANDLOCK_ACCESS_NET_BIND_UDP |
					 LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP);
    ...
}

Will this cause these tests to silently skip ruleset application or incorrectly
fail if a new sandbox variant (such as MPTCP) is added in the future?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830201650.67050-1-gnoack3000@gmail.com?part=2

  reply	other threads:[~2026-08-30 20:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 20:16 [PATCH 0/6] landlock: Support MPTCP bind and connect restrictions Günther Noack
2026-08-30 20:16 ` [PATCH 1/6] samples/landlock: Implement best-effort fallback for network rules Günther Noack
2026-08-30 20:25   ` sashiko-bot
2026-08-30 20:16 ` [PATCH 2/6] selftests/landlock: Generalize net test helpers for multiple socket types Günther Noack
2026-08-30 20:28   ` sashiko-bot [this message]
2026-08-30 20:16 ` [PATCH 3/6] landlock: Add MPTCP bind and connect access rights Günther Noack
2026-08-31  4:09   ` Geliang Tang
2026-08-30 20:16 ` [PATCH 4/6] selftests/landlock: Add MPTCP network access tests Günther Noack
2026-08-30 20:27   ` sashiko-bot
2026-08-30 20:16 ` [PATCH 5/6] samples/landlock: Support MPTCP access rights Günther Noack
2026-08-30 20:16 ` [PATCH 6/6] landlock: Document " Günther Noack
2026-08-30 21:06 ` [PATCH 0/6] landlock: Support MPTCP bind and connect restrictions MPTCP CI

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=20260830202851.57A281F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gnoack3000@gmail.com \
    --cc=mptcp@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox