[RFC PATCH 0/1] lsm: Add hook unix_path_connect
Justin Suess
utilityemal77 at gmail.com
Mon Jan 5 16:04:59 UTC 2026
On 1/5/26 06:04, Günther Noack wrote:
> Hello!
>
> On Sun, Jan 04, 2026 at 11:46:46PM -0800, Kuniyuki Iwashima wrote:
>> On Wed, Dec 31, 2025 at 1:33 PM Justin Suess <utilityemal77 at gmail.com> wrote:
>>> Motivation
>>> ---
>>>
>>> For AF_UNIX sockets bound to a filesystem path (aka named sockets), one
>>> identifying object from a policy perspective is the path passed to
>>> connect(2). However, this operation currently restricts LSMs that rely
>>> on VFS-based mediation, because the pathname resolved during connect()
>>> is not preserved in a form visible to existing hooks before connection
>>> establishment.
>> Why can't LSM use unix_sk(other)->path in security_unix_stream_connect()
>> and security_unix_may_send() ?
> Thanks for bringing it up!
>
> That path is set by the process that acts as the listening side for
> the socket. The listening and the connecting process might not live
> in the same mount namespace, and in that case, it would not match the
> path which is passed by the client in the struct sockaddr_un.
Agreed. For the unix_sk(other)->path method you described to work, it requires the
programs to be in the same mount namespace.
Doing it this way would make it impossible for landlock to restrict sockets mounted into a container,
and would be very confusing behavior for users to deal with, which is exactly the kind of stuff landlock avoids.
Does anyone have any thoughts on ignoring SOCK_COREDUMP? I think ignoring it for this check is correct.
>
> For more details, see
> https://lore.kernel.org/all/20260101134102.25938-1-gnoack3000@gmail.com/
> and
> https://github.com/landlock-lsm/linux/issues/36#issuecomment-2950632277
>
> Justin: Maybe we could add that reasoning to the cover letter in the
> next version of the patch?
>
> –Günther
Will do. It's about ready to go, I may resend it today if I have time.
More information about the Linux-security-module-archive
mailing list