Subject: Re: AF_UNIX sockets crossing namespace based boundaries

From: [email-masked] (Eric W. Biederman)
Date: Thu, 17 Jan 2019 22:47:21 -0600

Andrew Lunn <[email-masked]> writes:

> On Wed, Jan 02, 2019 at 10:22:36AM -0500, Donald Sharp wrote:
>> I am only creating a network namespace, but I don't think this changes
>> my core question.
>> 
>> Suppose I am running FRR/zebra in the default namespace and I startup
>> a BGP instance in namespace one.  BGP will connect to the default
>> namespaces zebra instance.
>
> Hi David.
>
> We are talking about AF_UNIX here. By default, the name of the socket
> is a path on a filesystem. So to me, netns plays no role here when you
> reference the socket via its filesystem name. The path exists in the
> filesystem namespace, and in your case with only netns, the same path
> exists in all your netns.
>
> Linux has multiple namespaces, which in theory should be
> orthogonal. However in practice, they do sometime overlap, and this is
> one example. There are other examples, /proc files are also netns
> unaware. It seems like having an object depend on two different
> namespaces at the same time is simply not supported.

To clarify.

It was a deliberate design choice to allow connecting to a af_unix
socket with a presence in a filesystem from other network namespaces.

We audited the code to ensure that, that case would work without
problems before actually allowing it.

Long story short.  If two processes can communicate through the
filesystem then we allow creating an af_unix socket in the filesystem
they can communicate through.

Eric