Linux Security Modules development
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Oxana Kharitonova <oxana@cloudflare.com>
Cc: gnoack@google.com, paul@paul-moore.com, serge@hallyn.com,
	 wangyan01@kylinos.cn, linux-security-module@vger.kernel.org,
	 linux-kernel@vger.kernel.org, landlock@lists.linux.dev,
	webprosto@gmail.com
Subject: Re: [PATCH 5/6] samples/landlock: Support POSIX message queue scoping
Date: Tue, 28 Jul 2026 13:04:24 +0200	[thread overview]
Message-ID: <20260728.Ro3ni9Cee9es@digikod.net> (raw)
In-Reply-To: <20260722122952.42149-6-oxana@cloudflare.com>

On Wed, Jul 22, 2026 at 01:29:41PM +0100, Oxana Kharitonova wrote:
> Teach the sandboxer sample to request LANDLOCK_SCOPE_POSIX_MSG_QUEUE
> through LL_SCOPED.
> 
> Add the "q" scope selector for POSIX message queues and document it in
> the sample help text. Also allow POSIX message queue denials to be
> quieted with "posix_msg_queue" through LL_QUIET_ACCESS.

This commit message should contains an example to prove with this
sandboxer that the scope actually works, or at least to show how to use
it.

> 
> Signed-off-by: Oxana Kharitonova <oxana@cloudflare.com>
> ---
>  samples/landlock/sandboxer.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c
> index ac71019e6212..59024ca53398 100644
> --- a/samples/landlock/sandboxer.c
> +++ b/samples/landlock/sandboxer.c
> @@ -240,10 +240,12 @@ static bool check_ruleset_scope(const char *const env_var,
>  	bool error = false;
>  	bool abstract_scoping = false;
>  	bool signal_scoping = false;
> +	bool posix_mqueue_scoping = false;
>  
>  	/* Scoping is not supported by Landlock ABI */
>  	if (!(ruleset_attr->scoped &
> -	      (LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET | LANDLOCK_SCOPE_SIGNAL)))
> +	      (LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET | LANDLOCK_SCOPE_SIGNAL |
> +	       LANDLOCK_SCOPE_POSIX_MSG_QUEUE)))
>  		goto out_unset;
>  
>  	env_type_scope = getenv(env_var);
> @@ -260,6 +262,9 @@ static bool check_ruleset_scope(const char *const env_var,
>  		} else if (strcmp("s", ipc_scoping_name) == 0 &&
>  			   !signal_scoping) {
>  			signal_scoping = true;
> +		} else if (strcmp("q", ipc_scoping_name) == 0 &&
> +			   !posix_mqueue_scoping) {
> +			posix_mqueue_scoping = true;
>  		} else {
>  			fprintf(stderr, "Unknown or duplicate scope \"%s\"\n",
>  				ipc_scoping_name);
> @@ -276,6 +281,8 @@ static bool check_ruleset_scope(const char *const env_var,
>  		ruleset_attr->scoped &= ~LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET;
>  	if (!signal_scoping)
>  		ruleset_attr->scoped &= ~LANDLOCK_SCOPE_SIGNAL;
> +	if (!posix_mqueue_scoping)
> +		ruleset_attr->scoped &= ~LANDLOCK_SCOPE_POSIX_MSG_QUEUE;
>  
>  	unsetenv(env_var);
>  	return error;
> @@ -354,6 +361,9 @@ static int add_quiet_access(const char *const env_var,
>  				LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET;
>  		else if (strcmp(str_access, "signal") == 0)
>  			ruleset_attr->quiet_scoped |= LANDLOCK_SCOPE_SIGNAL;
> +		else if (strcmp(str_access, "posix_msg_queue") == 0)
> +			ruleset_attr->quiet_scoped |=
> +				LANDLOCK_SCOPE_POSIX_MSG_QUEUE;
>  		else {
>  			fprintf(stderr, "Unknown quiet access \"%s\"\n",
>  				str_access);
> @@ -400,6 +410,7 @@ static const char help[] =
>  	"* " ENV_SCOPED_NAME ": actions denied on the outside of the landlock domain\n"
>  	"  - \"a\" to restrict opening abstract unix sockets\n"
>  	"  - \"s\" to restrict sending signals\n"
> +	"  - \"q\" to restrict opening POSIX message queues\n"
>  	"\n"
>  	"A sandboxer should not log denied access requests to avoid spamming logs, "
>  	"but to test audit we can set " ENV_FORCE_LOG_NAME "=1\n"
> @@ -416,6 +427,7 @@ static const char help[] =
>  	"  - \"udp_connect\" to quiet udp connect / send denials\n"
>  	"  - \"abstract_unix_socket\" to quiet abstract unix socket denials\n"
>  	"  - \"signal\" to quiet signal denials\n"
> +	"  - \"posix_msg_queue\" to quiet POSIX message queue denials\n"
>  	"\n"
>  	"Example:\n"
>  	ENV_FS_RO_NAME "=\"${PATH}:/lib:/usr:/proc:/etc:/dev/urandom\" "
> @@ -423,7 +435,7 @@ static const char help[] =
>  	ENV_TCP_BIND_NAME "=\"9418\" "
>  	ENV_TCP_CONNECT_NAME "=\"80:443\" "
>  	ENV_UDP_CONNECT_SEND_NAME "=\"53\" "
> -	ENV_SCOPED_NAME "=\"a:s\" "
> +	ENV_SCOPED_NAME "=\"a:s:q\" "
>  	"%1$s bash -i\n"
>  	"\n"
>  	"This sandboxer can use Landlock features up to ABI version "
> -- 
> 2.50.1 (Apple Git-155)
> 
> 

  reply	other threads:[~2026-07-28 11:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 12:29 [PATCH 0/6] landlock: Add POSIX message queue scoping Oxana Kharitonova
2026-07-22 12:29 ` [PATCH 1/6] ipc: Move mqueue fs magic to uapi magic header Oxana Kharitonova
2026-07-22 12:43   ` Günther Noack
2026-07-22 15:14     ` Oxana Kharitonova
2026-07-22 12:29 ` [PATCH 2/6] landlock: Scope POSIX message queue opens Oxana Kharitonova
2026-07-23 21:59   ` Justin Suess
2026-07-28 11:03   ` Mickaël Salaün
2026-07-22 12:29 ` [PATCH 3/6] landlock: Bump ABI for LANDLOCK_SCOPE_POSIX_MSG_QUEUE Oxana Kharitonova
2026-07-28 11:03   ` Mickaël Salaün
2026-07-22 12:29 ` [PATCH 4/6] selftests/landlock: Test POSIX message queue scoping Oxana Kharitonova
2026-07-28 11:04   ` Mickaël Salaün
2026-07-22 12:29 ` [PATCH 5/6] samples/landlock: Support " Oxana Kharitonova
2026-07-28 11:04   ` Mickaël Salaün [this message]
2026-07-22 12:29 ` [PATCH 6/6] landlock: Document " Oxana Kharitonova
2026-07-28 11:02 ` [PATCH 0/6] landlock: Add " Mickaël Salaün

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=20260728.Ro3ni9Cee9es@digikod.net \
    --to=mic@digikod.net \
    --cc=gnoack@google.com \
    --cc=landlock@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=oxana@cloudflare.com \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=wangyan01@kylinos.cn \
    --cc=webprosto@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