[PATCH v10 1/6] Landlock: Add abstract UNIX socket connect restriction

Simon Horman horms at kernel.org
Tue Aug 20 19:14:36 UTC 2024


On Mon, Aug 19, 2024 at 10:08:51PM -0600, Tahera Fahimi wrote:
> This patch introduces a new "scoped" attribute to the landlock_ruleset_attr
> that can specify "LANDLOCK_SCOPED_ABSTRACT_UNIX_SOCKET" to scope
> abstract UNIX sockets from connecting to a process outside of
> the same Landlock domain. It implements two hooks, unix_stream_connect
> and unix_may_send to enforce this restriction.
> 
> Closes: https://github.com/landlock-lsm/linux/issues/7
> Signed-off-by: Tahera Fahimi <fahimitahera at gmail.com>

...

> diff --git a/security/landlock/task.c b/security/landlock/task.c

...

> @@ -108,9 +110,134 @@ static int hook_ptrace_traceme(struct task_struct *const parent)
>  	return task_ptrace(parent, current);
>  }
>  
> +/**
> + * domain_is_scoped - Checks if the client domain is scoped in the same
> + *			domain as the server.
> + *
> + * @client: IPC sender domain.
> + * @server: IPC receiver domain.

nit: @scope should be documented here.

> + *
> + * Return true if the @client domain is scoped to access the @server,

nit: Kernel doc returns sections start with "Return:" or "Returns:".
     It might be worth using that syntax here.

> + * unless the @server is also scoped in the same domain as @client.
> + */
> +static bool domain_is_scoped(const struct landlock_ruleset *const client,
> +			     const struct landlock_ruleset *const server,
> +			     access_mask_t scope)

...



More information about the Linux-security-module-archive mailing list