Check out my first novel, midnight's simulacra!
Questions: Difference between revisions
From dankwiki
(Created page with 'Some questions I've pondered, and my answers, which may or may not be correct. ==UNIX== Q: Why are PF_UNIX sockets the only means of exchanging file descriptors (why not regular...') |
(→UNIX) |
||
Line 2: | Line 2: | ||
==UNIX== | ==UNIX== | ||
Q: Why are PF_UNIX sockets the only means of exchanging file descriptors (why not regular pipes? why not PF_INET or PF_INET6 sockets?) | *Q: Why are PF_UNIX sockets the only means of exchanging file descriptors (why not regular pipes? why not PF_INET or PF_INET6 sockets?) | ||
A: The socket infrastructure provided sufficient mechanism -- <tt>recvmsg(2)/sendmsg(2)</tt>, <tt>struct msghdr</tt> etc. Regular pipes don't have out-of-band signaling capabilities, as used by the <tt>SCM_RIGHTS cmsg_type</tt>. File descriptors index a kernelspace array, and thus any non-local socket family would introduce the possibility of a copy of those structures (if that is even meaningful and possible in a given context). Furthermore, they're credentials, in that access checks have already been performed; a socket family involving peers not trusted by the local kernel could subvert the [http://en.wikipedia.org/wiki/Access_control access control]. | *A: The socket infrastructure provided sufficient mechanism -- <tt>recvmsg(2)/sendmsg(2)</tt>, <tt>struct msghdr</tt> etc. Regular pipes don't have out-of-band signaling capabilities, as used by the <tt>SCM_RIGHTS cmsg_type</tt>. File descriptors index a kernelspace array, and thus any non-local socket family would introduce the possibility of a copy of those structures (if that is even meaningful and possible in a given context). Furthermore, they're credentials, in that access checks have already been performed; a socket family involving peers not trusted by the local kernel could subvert the [http://en.wikipedia.org/wiki/Access_control access control]. |
Revision as of 17:25, 21 June 2009
Some questions I've pondered, and my answers, which may or may not be correct.
UNIX
- Q: Why are PF_UNIX sockets the only means of exchanging file descriptors (why not regular pipes? why not PF_INET or PF_INET6 sockets?)
- A: The socket infrastructure provided sufficient mechanism -- recvmsg(2)/sendmsg(2), struct msghdr etc. Regular pipes don't have out-of-band signaling capabilities, as used by the SCM_RIGHTS cmsg_type. File descriptors index a kernelspace array, and thus any non-local socket family would introduce the possibility of a copy of those structures (if that is even meaningful and possible in a given context). Furthermore, they're credentials, in that access checks have already been performed; a socket family involving peers not trusted by the local kernel could subvert the access control.