Skip to contentSkip to conversation

net/unix: Allow Unix sockets to be treated like normal files

PATCH In review [email protected] 2 participants 3 messages Oct 28, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/unix: Allow Unix sockets to be treated like normal files

From: Jeff Hansen <[email protected]>

Resent. Is there anything else I need to do for this patch to get reviewed and/or merged? Any comments by anyone?

This allows Unix sockets to be opened, written, read, and closed, like normal files. This can be especially handy from, for example, a shell script that wants to send a short message to a Unix socket, but doesn't want to and/or cannot create the socket itself.

This will try to open the Unix socket first in SOCK_DGRAM mode, then SOCK_STREAM mode if that fails.

---
 net/unix/Kconfig   |   10 +++++
 net/unix/af_unix.c |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+), 0 deletions(-)
net/unix/Kconfig +10 -0
index 5a69733..68df4f1 100644
@@ -19,3 +19,13 @@ config UNIX
 
 	  Say Y unless you know what you are doing.
 
+config UNIX_FOPS
+	boolean "Allow Unix sockets to be treated like normal files"
+	depends on UNIX
+	---help---
+	  If you say Y here, Unix sockets may be opened, written, read, and
+	  closed, like normal files.  This is handy for sending short commands
+	  to Unix sockets (i.e. from shell scripts), without having to create
+	  a Unix socket.
+
+	  Say Y unless you know what you are doing.
net/unix/af_unix.c +113 -0

125 lines not on this page · raw message

Signature · 1 line
1.7.0.4
maintainer
#1 lore raw

From: [email protected]
Date: Thu, 28 Oct 2010 02:24:29 +0000

Quoted 2 lines

Resent. Is there anything else I need to do for this patch to get reviewed and/or merged? Any comments by anyone?

I don't like this idea at all.

I remember there is a reason why similar things are not allowed for sockets, it causes all sorts of problems although I forget the exact details.

Take a look at net/socket.c:sock_no_open(), for example.

#2 lore raw

Dave,

I agree that on larger systems this doesn't really make sense, but on embedded platforms this can save some code space since applications can get rid of their FIFO listeners and have strictly socket listeners. That's why I made it an option that could be disabled by default.

Do you know who originally suggested that "creepy crawlies" are introduced by allowing sockets to be opened? I'd be interested to know how this could affect security, if at all.

-Jeff

Quoted 13 lines · David Miller

From: [email protected]
Date: Thu, 28 Oct 2010 02:24:29 +0000

Quoted 2 lines

Resent. Is there anything else I need to do for this patch to get reviewed and/or merged? Any comments by anyone?

I don't like this idea at all.

I remember there is a reason why similar things are not allowed for sockets, it causes all sorts of problems although I forget the exact details.

Take a look at net/socket.c:sock_no_open(), for example.

Signature · 3 lines
---------------------------------------------------
"If someone's gotta do it, it might as well be me."
                [email protected]