<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/unix, branch linux-2.6.23.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.23.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.23.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2007-12-14T17:51:07Z</updated>
<entry>
<title>UNIX: EOF on non-blocking SOCK_SEQPACKET</title>
<updated>2007-12-14T17:51:07Z</updated>
<author>
<name>Florian Zumbiehl</name>
</author>
<published>2007-12-11T01:39:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5b5581b721cdc76fe1fe8f89f22ae613198acdbd'/>
<id>urn:sha1:5b5581b721cdc76fe1fe8f89f22ae613198acdbd</id>
<content type='text'>
[UNIX]: EOF on non-blocking SOCK_SEQPACKET

[ Upstream commit: 0a11225887fe6cbccd882404dc36ddc50f47daf9 ]

I am not absolutely sure whether this actually is a bug (as in: I've got
no clue what the standards say or what other implementations do), but at
least I was pretty surprised when I noticed that a recv() on a
non-blocking unix domain socket of type SOCK_SEQPACKET (which is connection
oriented, after all) where the remote end has closed the connection
returned -1 (EAGAIN) rather than 0 to indicate end of file.

This is a test case:

| #include &lt;sys/types.h&gt;
| #include &lt;unistd.h&gt;
| #include &lt;sys/socket.h&gt;
| #include &lt;sys/un.h&gt;
| #include &lt;fcntl.h&gt;
| #include &lt;string.h&gt;
| #include &lt;stdlib.h&gt;
|
| int main(){
| 	int sock;
| 	struct sockaddr_un addr;
| 	char buf[4096];
| 	int pfds[2];
|
| 	pipe(pfds);
| 	sock=socket(PF_UNIX,SOCK_SEQPACKET,0);
| 	addr.sun_family=AF_UNIX;
| 	strcpy(addr.sun_path,"/tmp/foobar_testsock");
| 	bind(sock,(struct sockaddr *)&amp;addr,sizeof(addr));
| 	listen(sock,1);
| 	if(fork()){
| 		close(sock);
| 		sock=socket(PF_UNIX,SOCK_SEQPACKET,0);
| 		connect(sock,(struct sockaddr *)&amp;addr,sizeof(addr));
| 		fcntl(sock,F_SETFL,fcntl(sock,F_GETFL)|O_NONBLOCK);
| 		close(pfds[1]);
| 		read(pfds[0],buf,sizeof(buf));
| 		recv(sock,buf,sizeof(buf),0); // &lt;-- this one
| 	}else accept(sock,NULL,NULL);
| 	exit(0);
| }

If you try it, make sure /tmp/foobar_testsock doesn't exist.

The marked recv() returns -1 (EAGAIN) on 2.6.23.9. Below you find a
patch that fixes that.

Signed-off-by: Florian Zumbiehl &lt;florz@florz.de&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>[AF_UNIX]: Make code static.</title>
<updated>2007-07-31T09:28:27Z</updated>
<author>
<name>Adrian Bunk</name>
</author>
<published>2007-07-31T01:05:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=131116989b5c349f9b1ab9ee083d37cc73160ac8'/>
<id>urn:sha1:131116989b5c349f9b1ab9ee083d37cc73160ac8</id>
<content type='text'>
The following code can now become static:
- struct unix_socket_table
- unix_table_lock

Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[AF_UNIX]: Rewrite garbage collector, fixes race.</title>
<updated>2007-07-11T21:22:39Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2007-07-11T21:22:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1fd05ba5a2f2aa8e7b9b52ef55df850e2e7d54c9'/>
<id>urn:sha1:1fd05ba5a2f2aa8e7b9b52ef55df850e2e7d54c9</id>
<content type='text'>
Throw out the old mark &amp; sweep garbage collector and put in a
refcounting cycle detecting one.

The old one had a race with recvmsg, that resulted in false positives
and hence data loss.  The old algorithm operated on all unix sockets
in the system, so any additional locking would have meant performance
problems for all users of these.

The new algorithm instead only operates on "in flight" sockets, which
are very rare, and the additional locking for these doesn't negatively
impact the vast majority of users.

In fact it's probable, that there weren't *any* heavy senders of
sockets over sockets, otherwise the above race would have been
discovered long ago.

The patch works OK with the app that exposed the race with the old
code.  The garbage collection has also been verified to work in a few
simple cases.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[NET]: Make all initialized struct seq_operations const.</title>
<updated>2007-07-11T06:07:31Z</updated>
<author>
<name>Philippe De Muyter</name>
</author>
<published>2007-07-11T06:07:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=56b3d975bbce65f655c5612b4822da671f9fd9b2'/>
<id>urn:sha1:56b3d975bbce65f655c5612b4822da671f9fd9b2</id>
<content type='text'>
Make all initialized struct seq_operations in net/ const

Signed-off-by: Philippe De Muyter &lt;phdm@macqel.be&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[AF_UNIX]: Fix stream recvmsg() race.</title>
<updated>2007-06-07T20:40:44Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2007-06-05T20:10:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3c0d2f3780fc94746c4842e965bd2570e2119bb6'/>
<id>urn:sha1:3c0d2f3780fc94746c4842e965bd2570e2119bb6</id>
<content type='text'>
A recv() on an AF_UNIX, SOCK_STREAM socket can race with a
send()+close() on the peer, causing recv() to return zero, even though
the sent data should be received.

This happens if the send() and the close() is performed between
skb_dequeue() and checking sk-&gt;sk_shutdown in unix_stream_recvmsg():

process A  skb_dequeue() returns NULL, there's no data in the socket queue
process B  new data is inserted onto the queue by unix_stream_sendmsg()
process B  sk-&gt;sk_shutdown is set to SHUTDOWN_MASK by unix_release_sock()
process A  sk-&gt;sk_shutdown is checked, unix_release_sock() returns zero

I'm surprised nobody noticed this, it's not hard to trigger.  Maybe
it's just (un)luck with the timing.

It's possible to work around this bug in userspace, by retrying the
recv() once in case of a zero return value.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[AF_UNIX]: Fix datagram connect race causing an OOPS.</title>
<updated>2007-06-04T01:08:42Z</updated>
<author>
<name>David S. Miller</name>
</author>
<published>2007-05-31T22:19:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=278a3de5abc7901805689a66340b5af9882b4f9a'/>
<id>urn:sha1:278a3de5abc7901805689a66340b5af9882b4f9a</id>
<content type='text'>
Based upon an excellent bug report and initial patch by
Frederik Deweerdt.

The UNIX datagram connect code blindly dereferences other-&gt;sk_socket
via the call down to the security_unix_may_send() function.

Without locking 'other' that pointer can go NULL via unix_release_sock()
which does sock_orphan() which also marks the socket SOCK_DEAD.

So we have to lock both 'sk' and 'other' yet avoid all kinds of
potential deadlocks (connect to self is OK for datagram sockets and it
is possible for two datagram sockets to perform a simultaneous connect
to each other).  So what we do is have a "double lock" function similar
to how we handle this situation in other areas of the kernel.  We take
the lock of the socket pointer with the smallest address first in
order to avoid ABBA style deadlocks.

Once we have them both locked, we check to see if SOCK_DEAD is set
for 'other' and if so, drop everything and retry the lookup.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[AF_UNIX]: Make socket locking much less confusing.</title>
<updated>2007-06-04T01:08:40Z</updated>
<author>
<name>David S. Miller</name>
</author>
<published>2007-05-31T20:24:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1c92b4e50ef926d1e26fcc056a520e4a7d12478c'/>
<id>urn:sha1:1c92b4e50ef926d1e26fcc056a520e4a7d12478c</id>
<content type='text'>
The unix_state_*() locking macros imply that there is some
rwlock kind of thing going on, but the implementation is
actually a spinlock which makes the code more confusing than
it needs to be.

So use plain unix_state_lock and unix_state_unlock.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>header cleaning: don't include smp_lock.h when not used</title>
<updated>2007-05-08T18:15:07Z</updated>
<author>
<name>Randy Dunlap</name>
</author>
<published>2007-05-08T07:28:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e63340ae6b6205fef26b40a75673d1c9c0c8bb90'/>
<id>urn:sha1:e63340ae6b6205fef26b40a75673d1c9c0c8bb90</id>
<content type='text'>
Remove includes of &lt;linux/smp_lock.h&gt; where it is not used/needed.
Suggested by Al Viro.

Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
sparc64, and arm (all 59 defconfigs).

Signed-off-by: Randy Dunlap &lt;randy.dunlap@oracle.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>[SK_BUFF]: Introduce skb_reset_transport_header(skb)</title>
<updated>2007-04-26T05:25:15Z</updated>
<author>
<name>Arnaldo Carvalho de Melo</name>
</author>
<published>2007-03-13T16:06:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=badff6d01a8589a1c828b0bf118903ca38627f4e'/>
<id>urn:sha1:badff6d01a8589a1c828b0bf118903ca38627f4e</id>
<content type='text'>
For the common, open coded 'skb-&gt;h.raw = skb-&gt;data' operation, so that we can
later turn skb-&gt;h.raw into a offset, reducing the size of struct sk_buff in
64bit land while possibly keeping it as a pointer on 32bit.

This one touches just the most simple cases:

skb-&gt;h.raw = skb-&gt;data;
skb-&gt;h.raw = {skb_push|[__]skb_pull}()

The next ones will handle the slightly more "complex" cases.

Signed-off-by: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>[NET]: Revert incorrect accept queue backlog changes.</title>
<updated>2007-03-06T19:21:05Z</updated>
<author>
<name>David S. Miller</name>
</author>
<published>2007-03-06T19:21:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=64a146513f8f12ba204b7bf5cb7e9505594ead42'/>
<id>urn:sha1:64a146513f8f12ba204b7bf5cb7e9505594ead42</id>
<content type='text'>
This reverts two changes:

8488df894d05d6fa41c2bd298c335f944bb0e401
248f06726e866942b3d8ca8f411f9067713b7ff8

A backlog value of N really does mean allow "N + 1" connections
to queue to a listening socket.  This allows one to specify
"0" as the backlog and still get 1 connection.

Noticed by Gerrit Renker and Rick Jones.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
