Bug #1056
closed
ksocket doesn't support AF_UNIX
Added by Stepan Zastupov about 11 years ago.
Updated almost 11 years ago.
Description
ksocket_socket() doesn't accept AF_UNIX and AF_NCA domains. I removed the check for AF_UNIX and wrote a simple echo client which speaks with user space server. It seems to work fine so I wonder, why AF_UNIX wasn't supported? Is there a known problem or just lack of testing?
Files
I'm pretty sure this was just paranoia, given that there were
no current consumers using the AF_UNIX code paths.
We need it to work now, to support another project we have
underway, but don't want to go public with just yet.
I attached the patch and a user-space echo server for testing. I have no kernel example but it works fine from my experience.
Perhaps Dan has some memory of why this is?
Does a change such as this require any extra protection in the face of zones? (to prevent someone in the context of zone A communicating with a socket in zone B?). A wild guess based on the choice of disallowed sockets.
After some time spent working with ksocket I realized that AF_UNIX wasn't supported by reason.
AF_UNIX support is implemented in socktpi.c of sockfs module and socktpi has some issues:
- socktpi doesn't use much of sockfs infrastructure like upcalls/downcalls which are capable of calling ksocket callbacks. Therefore, ksocket callbacks won't be ever called with AF_UNIX.
- socktpi can work in different modes (SOV_STREAM, SOV_SOCKSTREAM, SOV_SOCKBSD, etc...). Syscalls use SOV_SOCKBSD while ksocket uses SOV_DEFAULT (which is basically SOV_STREAM). So when socktpi works in SOV_STREAM mode it passes most of the calls directly to STREAMS. STREAMS assumes that the upper layer takes care of some ioctls (like FIONBIO). The problem is that socktpi doesn't handle FIONBIO for SOV_STREAM either. So basically, you can't turn socktpi ksocket to non-blocking mode.
- Message headers (of sendmsg()) are ignored for SOV_STREAM.
Probably the best solution would be to rewrite AF_UNIX using sockfs infrastructure but it's quite a lot of work. So the patch only removes check for AF_UNIX and adds workaround for the lack of the support for ksocket callbacks. ksocket_spoll() uses poll() infrastructure which is quite hairy, it allocates poll data structures on every call and it's overall ugly but it solves the problem. Feel free to propose a better solution without rewriting socktpi :)
- Status changed from Feedback to Resolved
changeset: 13477:3d8bcfed4059
tag: tip
user: Stepan Zastupov <stepan.zastupov@gmail.com>
date: Sun Oct 02 23:44:03 2011 +0400
description:
1056 ksocket doesn't support AF_UNIX
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Reviewed by: Garrett D'Amore <garrett.damore@gmail.com>
Approved by: Eric Schrock <eric.schrock@delphix.com>
Also available in: Atom
PDF