* [PATCH] net: change recvform to return same address length as getsockname on unnamed unix sockets
@ 2010-04-22 3:29 Pavel Pergamenshchik
2010-04-22 5:26 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Pergamenshchik @ 2010-04-22 3:29 UTC (permalink / raw)
To: netdev, davem; +Cc: linux-kernel
unix_*_recvmsg() returns zero-length sockaddr if the sender is an
unnamed AF_UNIX socket. Change it to return a two-byte sockaddr with
just the address family, to be consistent with unix_getname().
Signed-off-by: Pavel Pergamenshchik <ppergame@gmail.com>
---
Minimal example at http://xzrq.net/uaddrwtf.c
Solaris/OS X print 16 and 16. Linux prints 0 and 2 as described above.
--- a/net/unix/af_unix.c 2010-04-01 16:02:33.000000000 -0700
+++ b/net/unix/af_unix.c 2010-04-21 20:17:43.564703748 -0700
@@ -1634,9 +1634,13 @@
static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
{
struct unix_sock *u = unix_sk(sk);
+ struct sockaddr_un *sunaddr;
- msg->msg_namelen = 0;
- if (u->addr) {
+ if (!u->addr) {
+ msg->msg_namelen = sizeof(short);
+ sunaddr = msg->msg_name;
+ sunaddr->sun_family = AF_UNIX;
+ } else {
msg->msg_namelen = u->addr->len;
memcpy(msg->msg_name, u->addr->name, u->addr->len);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: change recvform to return same address length as getsockname on unnamed unix sockets
2010-04-22 3:29 [PATCH] net: change recvform to return same address length as getsockname on unnamed unix sockets Pavel Pergamenshchik
@ 2010-04-22 5:26 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-04-22 5:26 UTC (permalink / raw)
To: ppergame; +Cc: netdev, linux-kernel
From: Pavel Pergamenshchik <ppergame@gmail.com>
Date: Wed, 21 Apr 2010 20:29:25 -0700
> unix_*_recvmsg() returns zero-length sockaddr if the sender is an
> unnamed AF_UNIX socket. Change it to return a two-byte sockaddr with
> just the address family, to be consistent with unix_getname().
>
> Signed-off-by: Pavel Pergamenshchik <ppergame@gmail.com>
Since we've behaved this way for at least 10 years, the existing
behavior is the user visible ABI and the risk of breaking things by
making the change is too great.
I'm not applying this, sorry.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-22 5:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-22 3:29 [PATCH] net: change recvform to return same address length as getsockname on unnamed unix sockets Pavel Pergamenshchik
2010-04-22 5:26 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome