The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Michael Procter <lkml@procter-collective.org.uk>
To: kuznet@ms2.inr.ac.ru
Cc: linux-kernel@vger.kernel.org
Subject: Re: Unix-domain sockets - abstract addresses
Date: Fri, 9 Aug 2002 14:52:13 +0100	[thread overview]
Message-ID: <20020809145212.B1244@cad.citel.com> (raw)
In-Reply-To: <200208081836.WAA03110@sex.inr.ac.ru>; from kuznet@ms2.inr.ac.ru on Thu, Aug 08, 2002 at 10:36:38PM +0400

kuznet@ms2.inr.ac.ru wrote:
> 
> > According to the man page 'unix(7)':
> > When a socket is connected and it doesn't already have a local address a
> > unique address in the abstract namespace will be generated automatically.
> 
> This is wrong. The address is not autogenerated unless SO_PASSCRED
> is requested by security&compatibility reasons.
> So, if the socket is SOCK_DGRAM it is anounymous and "send-only",
> it is impossible to reply to it.

Why is the address not generated for 'security & compatibility' reasons? 
I've tried to think of a few reasons why this might be the case, but I
can't come up with anything very convincing.

I've been drawing parallels between PF_UNIX/SOCK_DGRAM and
PF_INET/SOCK_DGRAM.  From an interface point of view, they are very similar
(to the extend my app cares), apart from this lack of automatic address
generation for unix sockets.

It seems odd that you can send a message to another process, and for the
other end to have no way whatsoever of identifying the sender.  The same
situation in PF_INET doesn't exist - you get given a free port if you don't
specify one by the time you connect().


> > but I have seen 0x0BA5, 0x7FA8, 0x1FA8 and others).
> Yes, this is bug. The fix is enclosed. It should return nil address.

Thanks for the patch (thanks also to Thunder who sent one for 2.5).
However, there is still an inconsistency.  The function unix_getname()
will return just an address family if no address is present.  Here is a
diff that fixes this, and includes your change.

--- af_unix.c.orig	Fri Aug  9 14:10:05 2002
+++ af_unix.c	Fri Aug  9 14:17:38 2002
@@ -1101,9 +1101,7 @@
 
 	unix_state_rlock(sk);
 	if (!sk->protinfo.af_unix.addr)	{
-		sunaddr->sun_family = AF_UNIX;
-		sunaddr->sun_path[0] = 0;
-		*uaddr_len = sizeof(short);
+		*uaddr_len = 0;
 	} else {
 		struct unix_address *addr = sk->protinfo.af_unix.addr;
 
@@ -1385,7 +1383,7 @@
 
 static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
 {
-	msg->msg_namelen = sizeof(short);
+	msg->msg_namelen = 0;
 	if (sk->protinfo.af_unix.addr) {
 		msg->msg_namelen=sk->protinfo.af_unix.addr->len;
 		memcpy(msg->msg_name,


Regards,

Michael Procter

  parent reply	other threads:[~2002-08-09 13:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-08 16:15 Unix-domain sockets - abstract addresses Michael Procter
2002-08-08 18:36 ` kuznet
2002-08-09  0:29   ` Thunder from the hill
2002-08-09 13:52   ` Michael Procter [this message]
2002-08-09 16:15     ` kuznet
2002-08-09 22:33     ` Thunder from the hill
2002-08-10  1:05       ` David S. Miller
2002-08-10  1:35         ` Keith Owens
2002-08-10  1:41           ` David S. Miller
2002-08-10  2:19             ` Keith Owens
2002-08-10  2:15               ` David S. Miller
2002-08-10 10:59               ` Roman Zippel
2002-08-12  2:35               ` Oliver Xymoron
2002-08-12  2:59                 ` Keith Owens
2002-08-12  2:59                   ` David S. Miller
2002-08-12  3:20                     ` Keith Owens
2002-08-12  3:13                       ` David S. Miller
2002-08-12  3:57                         ` Keith Owens
2002-08-12  7:13                           ` Eric W. Biederman
2002-08-12 14:28                           ` David Woodhouse
2002-08-10  6:29         ` Thunder from the hill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020809145212.B1244@cad.citel.com \
    --to=lkml@procter-collective.org.uk \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox