[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG48ez39+ts9pNVvAxXcbk6X5_+s_yBXPUW-ZUNRxQq3aJAyrQ@mail.gmail.com>
Date: Tue, 6 Aug 2024 21:36:52 +0200
From: Jann Horn <jannh@...gle.com>
To: Tahera Fahimi <fahimitahera@...il.com>
Cc: outreachy@...ts.linux.dev, mic@...ikod.net, gnoack@...gle.com,
paul@...l-moore.com, jmorris@...ei.org, serge@...lyn.com,
linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org,
bjorn3_gh@...tonmail.com, netdev@...r.kernel.org
Subject: Re: [PATCH v8 1/4] Landlock: Add abstract unix socket connect restriction
On Fri, Aug 2, 2024 at 6:03 AM Tahera Fahimi <fahimitahera@...il.com> 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.
[...]
> +static bool check_unix_address_format(struct sock *const sock)
> +{
> + struct unix_address *addr = unix_sk(sock)->addr;
> +
> + if (!addr)
> + return true;
> +
> + if (addr->len > sizeof(AF_UNIX)) {
> + /* handling unspec sockets */
> + if (!addr->name[0].sun_path)
> + return true;
addr->name[0] is a "struct sockaddr_un", whose member "sun_path" is an
array member, not a pointer. If "addr" is a valid pointer,
"addr->name[0].sun_path" can't be NULL.
> + if (addr->name[0].sun_path[0] == '\0')
> + if (!sock_is_scoped(sock))
> + return false;
> + }
> +
> + return true;
> +}
Powered by blists - more mailing lists