Skip to contentSkip to conversation

netlink versus pid namespaces

DISCUSSION Andi Kleen 2 participants 5 messages Oct 15, 2010

Subsystems (3)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

Hi,

I have been trying to figure out how pid namespaces interact with netlink.

netlink uses pids (or really tids I hope?) to address sockets associated with processes.

The netlink code passes around pids without caring much about the pid namespace. It does pass around some information about the network namespace, but that doesn't help here because the pid namespace is not necessarily related to the net namespace.

When the netlink consumer runs in kernel (like rtnetlink) and happens to run in the same process context while receiving and processing the data it should do the right thing because it has the same pid namespace.

If it runs in some other process that is not guaranteed and it may actually send the reply back to the wrong pid.

When a process receives netlink in user space and it isn't in the same pid space as the sender it is unlikely that the reply gets back.

Anything I'm missing here?

Does netlink need to be extended?
Or perhaps forbid passing netlink between name spaces?

Thanks,
-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#1 lore raw

Hello!

Quoted 2 lines

netlink uses pids (or really tids I hope?) to address sockets associated with processes.

Not really. It uses port number which is called "pid" occasionally. Bad name. Autobind function simply selects tgid of calling process as the first guess.

Actually sockets are addressed by pair (net namespace, port) and communication is possible only inside net namespace. So, communication between namespaces is already prohibited.

pid namespaces do not participate in the picture at all.

Alexey

#2 lore raw
In reply to Andi Kleen

Hello!

Quoted 2 lines

netlink uses pids (or really tids I hope?) to address sockets associated with processes.

Not really. It uses port number which is called "pid" occasionally. Bad name. Autobind function simply selects tgid of calling process as the first guess.

Actually sockets are addressed by pair (net namespace, port) and communication is possible only inside net namespace. So, communication between namespaces is already prohibited.

pid namespaces do not participate in the picture at all.

Alexey

author
#3 lore raw
Quoted 7 lines · Alexey Kuznetsov

Hello!

Quoted 2 lines

netlink uses pids (or really tids I hope?) to address sockets associated with processes.

Not really. It uses port number which is called "pid" occasionally. Bad name. Autobind function simply selects tgid of calling process as the first guess.

Thanks for the clarification, Alexey. I guess I should have read more code :/

-Andi

author
#4 lore raw
In reply to Alexey Kuznetsov
Quoted 7 lines · Alexey Kuznetsov

Hello!

Quoted 2 lines

netlink uses pids (or really tids I hope?) to address sockets associated with processes.

Not really. It uses port number which is called "pid" occasionally. Bad name. Autobind function simply selects tgid of calling process as the first guess.

Thanks for the clarification, Alexey. I guess I should have read more code :/

-Andi