<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/core/sock.c, branch linux-2.6.36.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.36.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.36.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2010-09-25T05:26:10Z</updated>
<entry>
<title>net: fix a lockdep splat</title>
<updated>2010-09-25T05:26:10Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2010-09-22T12:43:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f064af1e500a2bf4607706f0f458163bdb2a6ea5'/>
<id>urn:sha1:f064af1e500a2bf4607706f0f458163bdb2a6ea5</id>
<content type='text'>
We have for each socket :

One spinlock (sk_slock.slock)
One rwlock (sk_callback_lock)

Possible scenarios are :

(A) (this is used in net/sunrpc/xprtsock.c)
read_lock(&amp;sk-&gt;sk_callback_lock) (without blocking BH)
&lt;BH&gt;
spin_lock(&amp;sk-&gt;sk_slock.slock);
...
read_lock(&amp;sk-&gt;sk_callback_lock);
...

(B)
write_lock_bh(&amp;sk-&gt;sk_callback_lock)
stuff
write_unlock_bh(&amp;sk-&gt;sk_callback_lock)

(C)
spin_lock_bh(&amp;sk-&gt;sk_slock)
...
write_lock_bh(&amp;sk-&gt;sk_callback_lock)
stuff
write_unlock_bh(&amp;sk-&gt;sk_callback_lock)
spin_unlock_bh(&amp;sk-&gt;sk_slock)

This (C) case conflicts with (A) :

CPU1 [A]                         CPU2 [C]
read_lock(callback_lock)
&lt;BH&gt;                             spin_lock_bh(slock)
&lt;wait to spin_lock(slock)&gt;
                                 &lt;wait to write_lock_bh(callback_lock)&gt;

We have one problematic (C) use case in inet_csk_listen_stop() :

local_bh_disable();
bh_lock_sock(child); // spin_lock_bh(&amp;sk-&gt;sk_slock)
WARN_ON(sock_owned_by_user(child));
...
sock_orphan(child); // write_lock_bh(&amp;sk-&gt;sk_callback_lock)

lockdep is not happy with this, as reported by Tetsuo Handa

It seems only way to deal with this is to use read_lock_bh(callbacklock)
everywhere.

Thanks to Jarek for pointing a bug in my first attempt and suggesting
this solution.

Reported-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Tested-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
CC: Jarek Poplawski &lt;jarkao2@gmail.com&gt;
Tested-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: this_cpu_xxx conversions</title>
<updated>2010-07-19T22:12:51Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2010-07-19T10:48:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d6d9ca0fec6aea0f2e4064474a1c5cdbed873c63'/>
<id>urn:sha1:d6d9ca0fec6aea0f2e4064474a1c5cdbed873c63</id>
<content type='text'>
Use modern this_cpu_xxx() api, saving few bytes on x86

Signed-off-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: sock_free() optimizations</title>
<updated>2010-07-13T03:21:46Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2010-07-10T22:45:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d361fd599a991ff6c1d522a599c635b35d61ef30'/>
<id>urn:sha1:d361fd599a991ff6c1d522a599c635b35d61ef30</id>
<content type='text'>
Avoid two extra instructions in sock_free(), to reload
skb-&gt;truesize and skb-&gt;sk

Signed-off-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: Export cred_to_ucred to modules.</title>
<updated>2010-06-16T23:18:25Z</updated>
<author>
<name>David S. Miller</name>
</author>
<published>2010-06-16T23:18:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3924773a5a82622167524bdd48799dc0452c57f8'/>
<id>urn:sha1:3924773a5a82622167524bdd48799dc0452c57f8</id>
<content type='text'>
AF_UNIX references this, and can be built as a module,
so...

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>af_unix: Allow SO_PEERCRED to work across namespaces.</title>
<updated>2010-06-16T21:55:55Z</updated>
<author>
<name>Eric W. Biederman</name>
</author>
<published>2010-06-13T03:30:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=109f6e39fa07c48f580125f531f46cb7c245b528'/>
<id>urn:sha1:109f6e39fa07c48f580125f531f46cb7c245b528</id>
<content type='text'>
Use struct pid and struct cred to store the peer credentials on struct
sock.  This gives enough information to convert the peer credential
information to a value relative to whatever namespace the socket is in
at the time.

This removes nasty surprises when using SO_PEERCRED on socket
connetions where the processes on either side are in different pid and
user namespaces.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: Daniel Lezcano &lt;daniel.lezcano@free.fr&gt;
Acked-by: Pavel Emelyanov &lt;xemul@openvz.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sock: Introduce cred_to_ucred</title>
<updated>2010-06-16T21:55:35Z</updated>
<author>
<name>Eric W. Biederman</name>
</author>
<published>2010-06-13T03:28:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3f551f9436c05a3b5eccdd6e94733df5bb98d2a5'/>
<id>urn:sha1:3f551f9436c05a3b5eccdd6e94733df5bb98d2a5</id>
<content type='text'>
To keep the coming code clear and to allow both the sock
code and the scm code to share the logic introduce a
fuction to translate from struct cred to struct ucred.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: Pavel Emelyanov &lt;xemul@openvz.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net-caif: Added missing lock validator constants</title>
<updated>2010-06-07T08:01:22Z</updated>
<author>
<name>Alex Lorca</name>
</author>
<published>2010-06-07T08:01:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fe33147a58e7d1d3086bf823aabfd491d843be82'/>
<id>urn:sha1:fe33147a58e7d1d3086bf823aabfd491d843be82</id>
<content type='text'>
CAIF is using "xxx-AF_MAX" strings for the lock validator. It should use
its own strings.

Signed-off-by: Alex Lorca &lt;alex.lorca@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: fix lock_sock_bh/unlock_sock_bh</title>
<updated>2010-05-27T07:30:53Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2010-05-26T19:20:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8a74ad60a546b13bd1096b2a61a7a5c6fd9ae17c'/>
<id>urn:sha1:8a74ad60a546b13bd1096b2a61a7a5c6fd9ae17c</id>
<content type='text'>
This new sock lock primitive was introduced to speedup some user context
socket manipulation. But it is unsafe to protect two threads, one using
regular lock_sock/release_sock, one using lock_sock_bh/unlock_sock_bh

This patch changes lock_sock_bh to be careful against 'owned' state.
If owned is found to be set, we must take the slow path.
lock_sock_bh() now returns a boolean to say if the slow path was taken,
and this boolean is used at unlock_sock_bh time to call the appropriate
unlock function.

After this change, BH are either disabled or enabled during the
lock_sock_bh/unlock_sock_bh protected section. This might be misleading,
so we rename these functions to lock_sock_fast()/unlock_sock_fast().

Reported-by: Anton Blanchard &lt;anton@samba.org&gt;
Signed-off-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Tested-by: Anton Blanchard &lt;anton@samba.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tun: Update classid on packet injection</title>
<updated>2010-05-24T07:14:10Z</updated>
<author>
<name>Herbert Xu</name>
</author>
<published>2010-05-24T07:14:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8286274284e15b11b0f531b6ceeef21fbe00a8dd'/>
<id>urn:sha1:8286274284e15b11b0f531b6ceeef21fbe00a8dd</id>
<content type='text'>
This patch makes tun update its socket classid every time we
inject a packet into the network stack.  This is so that any
updates made by the admin to the process writing packets to
tun is effected.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>cls_cgroup: Store classid in struct sock</title>
<updated>2010-05-24T07:12:34Z</updated>
<author>
<name>Herbert Xu</name>
</author>
<published>2010-05-24T07:12:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f845172531fb7410c7fb7780b1a6e51ee6df7d52'/>
<id>urn:sha1:f845172531fb7410c7fb7780b1a6e51ee6df7d52</id>
<content type='text'>
Up until now cls_cgroup has relied on fetching the classid out of
the current executing thread.  This runs into trouble when a packet
processing is delayed in which case it may execute out of another
thread's context.

Furthermore, even when a packet is not delayed we may fail to
classify it if soft IRQs have been disabled, because this scenario
is indistinguishable from one where a packet unrelated to the
current thread is processed by a real soft IRQ.

In fact, the current semantics is inherently broken, as a single
skb may be constructed out of the writes of two different tasks.
A different manifestation of this problem is when the TCP stack
transmits in response of an incoming ACK.  This is currently
unclassified.

As we already have a concept of packet ownership for accounting
purposes in the skb-&gt;sk pointer, this is a natural place to store
the classid in a persistent manner.

This patch adds the cls_cgroup classid in struct sock, filling up
an existing hole on 64-bit :)

The value is set at socket creation time.  So all sockets created
via socket(2) automatically gains the ID of the thread creating it.
Whenever another process touches the socket by either reading or
writing to it, we will change the socket classid to that of the
process if it has a valid (non-zero) classid.

For sockets created on inbound connections through accept(2), we
inherit the classid of the original listening socket through
sk_clone, possibly preceding the actual accept(2) call.

In order to minimise risks, I have not made this the authoritative
classid.  For now it is only used as a backup when we execute
with soft IRQs disabled.  Once we're completely happy with its
semantics we can use it as the sole classid.

Footnote: I have rearranged the error path on cls_group module
creation.  If we didn't do this, then there is a window where
someone could create a tc rule using cls_group before the cgroup
subsystem has been registered.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
