<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/net/tipc, branch v3.12.20</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>tipc: fix spinlock recursion bug for failed subscriptions</title>
<updated>2014-04-18T09:07:11+00:00</updated>
<author>
<name>Erik Hugne</name>
<email>erik.hugne@ericsson.com</email>
</author>
<published>2014-03-24T15:56:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=21a018a58f3c92c7e39ca38b84643bd187e397db'/>
<id>21a018a58f3c92c7e39ca38b84643bd187e397db</id>
<content type='text'>
[ Upstream commit a5d0e7c037119484a7006b883618bfa87996cb41 ]

If a topology event subscription fails for any reason, such as out
of memory, max number reached or because we received an invalid
request the correct behavior is to terminate the subscribers
connection to the topology server. This is currently broken and
produces the following oops:

[27.953662] tipc: Subscription rejected, illegal request
[27.955329] BUG: spinlock recursion on CPU#1, kworker/u4:0/6
[27.957066]  lock: 0xffff88003c67f408, .magic: dead4ead, .owner: kworker/u4:0/6, .owner_cpu: 1
[27.958054] CPU: 1 PID: 6 Comm: kworker/u4:0 Not tainted 3.14.0-rc6+ #5
[27.960230] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[27.960874] Workqueue: tipc_rcv tipc_recv_work [tipc]
[27.961430]  ffff88003c67f408 ffff88003de27c18 ffffffff815c0207 ffff88003de1c050
[27.962292]  ffff88003de27c38 ffffffff815beec5 ffff88003c67f408 ffffffff817f0a8a
[27.963152]  ffff88003de27c58 ffffffff815beeeb ffff88003c67f408 ffffffffa0013520
[27.964023] Call Trace:
[27.964292]  [&lt;ffffffff815c0207&gt;] dump_stack+0x45/0x56
[27.964874]  [&lt;ffffffff815beec5&gt;] spin_dump+0x8c/0x91
[27.965420]  [&lt;ffffffff815beeeb&gt;] spin_bug+0x21/0x26
[27.965995]  [&lt;ffffffff81083df6&gt;] do_raw_spin_lock+0x116/0x140
[27.966631]  [&lt;ffffffff815c6215&gt;] _raw_spin_lock_bh+0x15/0x20
[27.967256]  [&lt;ffffffffa0008540&gt;] subscr_conn_shutdown_event+0x20/0xa0 [tipc]
[27.968051]  [&lt;ffffffffa000fde4&gt;] tipc_close_conn+0xa4/0xb0 [tipc]
[27.968722]  [&lt;ffffffffa00101ba&gt;] tipc_conn_terminate+0x1a/0x30 [tipc]
[27.969436]  [&lt;ffffffffa00089a2&gt;] subscr_conn_msg_event+0x1f2/0x2f0 [tipc]
[27.970209]  [&lt;ffffffffa0010000&gt;] tipc_receive_from_sock+0x90/0xf0 [tipc]
[27.970972]  [&lt;ffffffffa000fa79&gt;] tipc_recv_work+0x29/0x50 [tipc]
[27.971633]  [&lt;ffffffff8105dbf5&gt;] process_one_work+0x165/0x3e0
[27.972267]  [&lt;ffffffff8105e869&gt;] worker_thread+0x119/0x3a0
[27.972896]  [&lt;ffffffff8105e750&gt;] ? manage_workers.isra.25+0x2a0/0x2a0
[27.973622]  [&lt;ffffffff810648af&gt;] kthread+0xdf/0x100
[27.974168]  [&lt;ffffffff810647d0&gt;] ? kthread_create_on_node+0x1a0/0x1a0
[27.974893]  [&lt;ffffffff815ce13c&gt;] ret_from_fork+0x7c/0xb0
[27.975466]  [&lt;ffffffff810647d0&gt;] ? kthread_create_on_node+0x1a0/0x1a0

The recursion occurs when subscr_terminate tries to grab the
subscriber lock, which is already taken by subscr_conn_msg_event.
We fix this by checking if the request to establish a new
subscription was successful, and if not we initiate termination of
the subscriber after we have released the subscriber lock.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit a5d0e7c037119484a7006b883618bfa87996cb41 ]

If a topology event subscription fails for any reason, such as out
of memory, max number reached or because we received an invalid
request the correct behavior is to terminate the subscribers
connection to the topology server. This is currently broken and
produces the following oops:

[27.953662] tipc: Subscription rejected, illegal request
[27.955329] BUG: spinlock recursion on CPU#1, kworker/u4:0/6
[27.957066]  lock: 0xffff88003c67f408, .magic: dead4ead, .owner: kworker/u4:0/6, .owner_cpu: 1
[27.958054] CPU: 1 PID: 6 Comm: kworker/u4:0 Not tainted 3.14.0-rc6+ #5
[27.960230] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[27.960874] Workqueue: tipc_rcv tipc_recv_work [tipc]
[27.961430]  ffff88003c67f408 ffff88003de27c18 ffffffff815c0207 ffff88003de1c050
[27.962292]  ffff88003de27c38 ffffffff815beec5 ffff88003c67f408 ffffffff817f0a8a
[27.963152]  ffff88003de27c58 ffffffff815beeeb ffff88003c67f408 ffffffffa0013520
[27.964023] Call Trace:
[27.964292]  [&lt;ffffffff815c0207&gt;] dump_stack+0x45/0x56
[27.964874]  [&lt;ffffffff815beec5&gt;] spin_dump+0x8c/0x91
[27.965420]  [&lt;ffffffff815beeeb&gt;] spin_bug+0x21/0x26
[27.965995]  [&lt;ffffffff81083df6&gt;] do_raw_spin_lock+0x116/0x140
[27.966631]  [&lt;ffffffff815c6215&gt;] _raw_spin_lock_bh+0x15/0x20
[27.967256]  [&lt;ffffffffa0008540&gt;] subscr_conn_shutdown_event+0x20/0xa0 [tipc]
[27.968051]  [&lt;ffffffffa000fde4&gt;] tipc_close_conn+0xa4/0xb0 [tipc]
[27.968722]  [&lt;ffffffffa00101ba&gt;] tipc_conn_terminate+0x1a/0x30 [tipc]
[27.969436]  [&lt;ffffffffa00089a2&gt;] subscr_conn_msg_event+0x1f2/0x2f0 [tipc]
[27.970209]  [&lt;ffffffffa0010000&gt;] tipc_receive_from_sock+0x90/0xf0 [tipc]
[27.970972]  [&lt;ffffffffa000fa79&gt;] tipc_recv_work+0x29/0x50 [tipc]
[27.971633]  [&lt;ffffffff8105dbf5&gt;] process_one_work+0x165/0x3e0
[27.972267]  [&lt;ffffffff8105e869&gt;] worker_thread+0x119/0x3a0
[27.972896]  [&lt;ffffffff8105e750&gt;] ? manage_workers.isra.25+0x2a0/0x2a0
[27.973622]  [&lt;ffffffff810648af&gt;] kthread+0xdf/0x100
[27.974168]  [&lt;ffffffff810647d0&gt;] ? kthread_create_on_node+0x1a0/0x1a0
[27.974893]  [&lt;ffffffff815ce13c&gt;] ret_from_fork+0x7c/0xb0
[27.975466]  [&lt;ffffffff810647d0&gt;] ? kthread_create_on_node+0x1a0/0x1a0

The recursion occurs when subscr_terminate tries to grab the
subscriber lock, which is already taken by subscr_conn_msg_event.
We fix this by checking if the request to establish a new
subscription was successful, and if not we initiate termination of
the subscriber after we have released the subscriber lock.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: don't log disabled tasklet handler errors</title>
<updated>2014-04-18T09:06:57+00:00</updated>
<author>
<name>Erik Hugne</name>
<email>erik.hugne@ericsson.com</email>
</author>
<published>2014-03-06T13:40:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d80441c0019881e72774fa3f51a09997b8214a46'/>
<id>d80441c0019881e72774fa3f51a09997b8214a46</id>
<content type='text'>
[ Upstream commit 2892505ea170094f982516bb38105eac45f274b1 ]

Failure to schedule a TIPC tasklet with tipc_k_signal because the
tasklet handler is disabled is not an error. It means TIPC is
currently in the process of shutting down. We remove the error
logging in this case.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 2892505ea170094f982516bb38105eac45f274b1 ]

Failure to schedule a TIPC tasklet with tipc_k_signal because the
tasklet handler is disabled is not an error. It means TIPC is
currently in the process of shutting down. We remove the error
logging in this case.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: fix memory leak during module removal</title>
<updated>2014-04-18T09:06:56+00:00</updated>
<author>
<name>Erik Hugne</name>
<email>erik.hugne@ericsson.com</email>
</author>
<published>2014-03-06T13:40:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=140490bca84bceb627da429ffceb03fb88b208e3'/>
<id>140490bca84bceb627da429ffceb03fb88b208e3</id>
<content type='text'>
[ Upstream commit 1bb8dce57f4d15233688c68990852a10eb1cd79f ]

When the TIPC module is removed, the tasklet handler is disabled
before all other subsystems. This will cause lingering publications
in the name table because the node_down tasklets responsible to
clean up publications from an unreachable node will never run.
When the name table is shut down, these publications are detected
and an error message is logged:
tipc: nametbl_stop(): orphaned hash chain detected
This is actually a memory leak, introduced with commit
993b858e37b3120ee76d9957a901cca22312ffaa ("tipc: correct the order
of stopping services at rmmod")

Instead of just logging an error and leaking memory, we free
the orphaned entries during nametable shutdown.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 1bb8dce57f4d15233688c68990852a10eb1cd79f ]

When the TIPC module is removed, the tasklet handler is disabled
before all other subsystems. This will cause lingering publications
in the name table because the node_down tasklets responsible to
clean up publications from an unreachable node will never run.
When the name table is shut down, these publications are detected
and an error message is logged:
tipc: nametbl_stop(): orphaned hash chain detected
This is actually a memory leak, introduced with commit
993b858e37b3120ee76d9957a901cca22312ffaa ("tipc: correct the order
of stopping services at rmmod")

Instead of just logging an error and leaking memory, we free
the orphaned entries during nametable shutdown.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: drop subscriber connection id invalidation</title>
<updated>2014-04-18T09:06:56+00:00</updated>
<author>
<name>Erik Hugne</name>
<email>erik.hugne@ericsson.com</email>
</author>
<published>2014-03-06T13:40:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=fa7a24eeb7d49ea81028b1ddb0921a6703fe1424'/>
<id>fa7a24eeb7d49ea81028b1ddb0921a6703fe1424</id>
<content type='text'>
[ Upstream commit edcc0511b5ee7235282a688cd604e3ae7f9e1fc9 ]

When a topology server subscriber is disconnected, the associated
connection id is set to zero. A check vs zero is then done in the
subscription timeout function to see if the subscriber have been
shut down. This is unnecessary, because all subscription timers
will be cancelled when a subscriber terminates. Setting the
connection id to zero is actually harmful because id zero is the
identity of the topology server listening socket, and can cause a
race that leads to this socket being closed instead.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit edcc0511b5ee7235282a688cd604e3ae7f9e1fc9 ]

When a topology server subscriber is disconnected, the associated
connection id is set to zero. A check vs zero is then done in the
subscription timeout function to see if the subscriber have been
shut down. This is unnecessary, because all subscription timers
will be cancelled when a subscriber terminates. Setting the
connection id to zero is actually harmful because id zero is the
identity of the topology server listening socket, and can cause a
race that leads to this socket being closed instead.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: fix connection refcount leak</title>
<updated>2014-04-18T09:06:55+00:00</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2014-03-06T13:40:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a9d796583feb5cfa2e2282e69a4963aa3492dfe6'/>
<id>a9d796583feb5cfa2e2282e69a4963aa3492dfe6</id>
<content type='text'>
[ Upstream commit 4652edb70e8a7eebbe47fa931940f65522c36e8f ]

When tipc_conn_sendmsg() calls tipc_conn_lookup() to query a
connection instance, its reference count value is increased if
it's found. But subsequently if it's found that the connection is
closed, the work of sending message is not queued into its server
send workqueue, and the connection reference count is not decreased.
This will cause a reference count leak. To reproduce this problem,
an application would need to open and closes topology server
connections with high intensity.

We fix this by immediately decrementing the connection reference
count if a send fails due to the connection being closed.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Acked-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 4652edb70e8a7eebbe47fa931940f65522c36e8f ]

When tipc_conn_sendmsg() calls tipc_conn_lookup() to query a
connection instance, its reference count value is increased if
it's found. But subsequently if it's found that the connection is
closed, the work of sending message is not queued into its server
send workqueue, and the connection reference count is not decreased.
This will cause a reference count leak. To reproduce this problem,
an application would need to open and closes topology server
connections with high intensity.

We fix this by immediately decrementing the connection reference
count if a send fails due to the connection being closed.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Acked-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: allow connection shutdown callback to be invoked in advance</title>
<updated>2014-04-18T09:06:54+00:00</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2014-03-06T13:40:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=1f92d32f63aef244e48d96b6d1abab64133b0d0c'/>
<id>1f92d32f63aef244e48d96b6d1abab64133b0d0c</id>
<content type='text'>
[ Upstream commit 6d4ebeb4df0176b1973875840a9f7e91394c0685 ]

Currently connection shutdown callback function is called when
connection instance is released in tipc_conn_kref_release(), and
receiving packets and sending packets are running in different
threads. Even if connection is closed by the thread of receiving
packets, its shutdown callback may not be called immediately as
the connection reference count is non-zero at that moment. So,
although the connection is shut down by the thread of receiving
packets, the thread of sending packets doesn't know it. Before
its shutdown callback is invoked to tell the sending thread its
connection has been closed, the sending thread may deliver
messages by tipc_conn_sendmsg(), this is why the following error
information appears:

"Sending subscription event failed, no memory"

To eliminate it, allow connection shutdown callback function to
be called before connection id is removed in tipc_close_conn(),
which makes the sending thread know the truth in time that its
socket is closed so that it doesn't send message to it. We also
remove the "Sending XXX failed..." error reporting for topology
and config services.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 6d4ebeb4df0176b1973875840a9f7e91394c0685 ]

Currently connection shutdown callback function is called when
connection instance is released in tipc_conn_kref_release(), and
receiving packets and sending packets are running in different
threads. Even if connection is closed by the thread of receiving
packets, its shutdown callback may not be called immediately as
the connection reference count is non-zero at that moment. So,
although the connection is shut down by the thread of receiving
packets, the thread of sending packets doesn't know it. Before
its shutdown callback is invoked to tell the sending thread its
connection has been closed, the sending thread may deliver
messages by tipc_conn_sendmsg(), this is why the following error
information appears:

"Sending subscription event failed, no memory"

To eliminate it, allow connection shutdown callback function to
be called before connection id is removed in tipc_close_conn(),
which makes the sending thread know the truth in time that its
socket is closed so that it doesn't send message to it. We also
remove the "Sending XXX failed..." error reporting for topology
and config services.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>net: rework recvmsg handler msg_name and msg_namelen logic</title>
<updated>2013-12-08T15:29:13+00:00</updated>
<author>
<name>Hannes Frederic Sowa</name>
<email>hannes@stressinduktion.org</email>
</author>
<published>2013-11-21T02:14:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0cefe287488ca07c0d7962a7b4d3fbb829d09917'/>
<id>0cefe287488ca07c0d7962a7b4d3fbb829d09917</id>
<content type='text'>
[ Upstream commit f3d3342602f8bcbf37d7c46641cb9bca7618eb1c ]

This patch now always passes msg-&gt;msg_namelen as 0. recvmsg handlers must
set msg_namelen to the proper size &lt;= sizeof(struct sockaddr_storage)
to return msg_name to the user.

This prevents numerous uninitialized memory leaks we had in the
recvmsg handlers and makes it harder for new code to accidentally leak
uninitialized memory.

Optimize for the case recvfrom is called with NULL as address. We don't
need to copy the address at all, so set it to NULL before invoking the
recvmsg handler. We can do so, because all the recvmsg handlers must
cope with the case a plain read() is called on them. read() also sets
msg_name to NULL.

Also document these changes in include/linux/net.h as suggested by David
Miller.

Changes since RFC:

Set msg-&gt;msg_name = NULL if user specified a NULL in msg_name but had a
non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
affect sendto as it would bail out earlier while trying to copy-in the
address. It also more naturally reflects the logic by the callers of
verify_iovec.

With this change in place I could remove "
if (!uaddr || msg_sys-&gt;msg_namelen == 0)
	msg-&gt;msg_name = NULL
".

This change does not alter the user visible error logic as we ignore
msg_namelen as long as msg_name is NULL.

Also remove two unnecessary curly brackets in ___sys_recvmsg and change
comments to netdev style.

Cc: David Miller &lt;davem@davemloft.net&gt;
Suggested-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: Hannes Frederic Sowa &lt;hannes@stressinduktion.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit f3d3342602f8bcbf37d7c46641cb9bca7618eb1c ]

This patch now always passes msg-&gt;msg_namelen as 0. recvmsg handlers must
set msg_namelen to the proper size &lt;= sizeof(struct sockaddr_storage)
to return msg_name to the user.

This prevents numerous uninitialized memory leaks we had in the
recvmsg handlers and makes it harder for new code to accidentally leak
uninitialized memory.

Optimize for the case recvfrom is called with NULL as address. We don't
need to copy the address at all, so set it to NULL before invoking the
recvmsg handler. We can do so, because all the recvmsg handlers must
cope with the case a plain read() is called on them. read() also sets
msg_name to NULL.

Also document these changes in include/linux/net.h as suggested by David
Miller.

Changes since RFC:

Set msg-&gt;msg_name = NULL if user specified a NULL in msg_name but had a
non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
affect sendto as it would bail out earlier while trying to copy-in the
address. It also more naturally reflects the logic by the callers of
verify_iovec.

With this change in place I could remove "
if (!uaddr || msg_sys-&gt;msg_namelen == 0)
	msg-&gt;msg_name = NULL
".

This change does not alter the user visible error logic as we ignore
msg_namelen as long as msg_name is NULL.

Also remove two unnecessary curly brackets in ___sys_recvmsg and change
comments to netdev style.

Cc: David Miller &lt;davem@davemloft.net&gt;
Suggested-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: Hannes Frederic Sowa &lt;hannes@stressinduktion.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: set sk_err correctly when connection fails</title>
<updated>2013-08-30T20:06:57+00:00</updated>
<author>
<name>Erik Hugne</name>
<email>erik.hugne@ericsson.com</email>
</author>
<published>2013-08-28T07:29:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2c8d85182348021fc0a1bed193a4be4161dc8364'/>
<id>2c8d85182348021fc0a1bed193a4be4161dc8364</id>
<content type='text'>
Should a connect fail, if the publication/server is unavailable or
due to some other error, a positive value will be returned and errno
is never set. If the application code checks for an explicit zero
return from connect (success) or a negative return (failure), it
will not catch the error and subsequent send() calls will fail as
shown from the strace snippet below.

socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
sendto(3, "test", 4, 0, NULL, 0)        = -1 EPIPE (Broken pipe)

The reason for this behaviour is that TIPC wrongly inverts error
codes set in sk_err.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Should a connect fail, if the publication/server is unavailable or
due to some other error, a positive value will be returned and errno
is never set. If the application code checks for an explicit zero
return from connect (success) or a negative return (failure), it
will not catch the error and subsequent send() calls will fail as
shown from the strace snippet below.

socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
sendto(3, "test", 4, 0, NULL, 0)        = -1 EPIPE (Broken pipe)

The reason for this behaviour is that TIPC wrongly inverts error
codes set in sk_err.

Signed-off-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: avoid possible deadlock while enable and disable bearer</title>
<updated>2013-08-12T04:58:41+00:00</updated>
<author>
<name>dingtianhong</name>
<email>dingtianhong@huawei.com</email>
</author>
<published>2013-08-09T09:12:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d4cca39d90fca21c04315095de5d0e734e839a8b'/>
<id>d4cca39d90fca21c04315095de5d0e734e839a8b</id>
<content type='text'>
We met lockdep warning when enable and disable the bearer for commands such as:

tipc-config -netid=1234 -addr=1.1.3 -be=eth:eth0
tipc-config -netid=1234 -addr=1.1.3 -bd=eth:eth0

---------------------------------------------------

[  327.693595] ======================================================
[  327.693994] [ INFO: possible circular locking dependency detected ]
[  327.694519] 3.11.0-rc3-wwd-default #4 Tainted: G           O
[  327.694882] -------------------------------------------------------
[  327.695385] tipc-config/5825 is trying to acquire lock:
[  327.695754]  (((timer))#2){+.-...}, at: [&lt;ffffffff8105be80&gt;] del_timer_sync+0x0/0xd0
[  327.696018]
[  327.696018] but task is already holding lock:
[  327.696018]  (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}, at: [&lt;ffffffffa02be58d&gt;] bearer_disable+  0xdd/0x120 [tipc]
[  327.696018]
[  327.696018] which lock already depends on the new lock.
[  327.696018]
[  327.696018]
[  327.696018] the existing dependency chain (in reverse order) is:
[  327.696018]
[  327.696018] -&gt; #1 (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}:
[  327.696018]        [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]        [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]        [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]        [&lt;ffffffff814d65b1&gt;] _raw_spin_lock_bh+0x41/0x80
[  327.696018]        [&lt;ffffffffa02c5d48&gt;] disc_timeout+0x18/0xd0 [tipc]
[  327.696018]        [&lt;ffffffff8105b92a&gt;] call_timer_fn+0xda/0x1e0
[  327.696018]        [&lt;ffffffff8105bcd7&gt;] run_timer_softirq+0x2a7/0x2d0
[  327.696018]        [&lt;ffffffff8105379a&gt;] __do_softirq+0x16a/0x2e0
[  327.696018]        [&lt;ffffffff81053a35&gt;] irq_exit+0xd5/0xe0
[  327.696018]        [&lt;ffffffff81033005&gt;] smp_apic_timer_interrupt+0x45/0x60
[  327.696018]        [&lt;ffffffff814df4af&gt;] apic_timer_interrupt+0x6f/0x80
[  327.696018]        [&lt;ffffffff8100b70e&gt;] arch_cpu_idle+0x1e/0x30
[  327.696018]        [&lt;ffffffff810a039d&gt;] cpu_idle_loop+0x1fd/0x280
[  327.696018]        [&lt;ffffffff810a043e&gt;] cpu_startup_entry+0x1e/0x20
[  327.696018]        [&lt;ffffffff81031589&gt;] start_secondary+0x89/0x90
[  327.696018]
[  327.696018] -&gt; #0 (((timer))#2){+.-...}:
[  327.696018]        [&lt;ffffffff810b33fe&gt;] check_prev_add+0x43e/0x4b0
[  327.696018]        [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]        [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]        [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]        [&lt;ffffffff8105bebd&gt;] del_timer_sync+0x3d/0xd0
[  327.696018]        [&lt;ffffffffa02c5855&gt;] tipc_disc_delete+0x15/0x30 [tipc]
[  327.696018]        [&lt;ffffffffa02be59f&gt;] bearer_disable+0xef/0x120 [tipc]
[  327.696018]        [&lt;ffffffffa02be74f&gt;] tipc_disable_bearer+0x2f/0x60 [tipc]
[  327.696018]        [&lt;ffffffffa02bfb32&gt;] tipc_cfg_do_cmd+0x2e2/0x550 [tipc]
[  327.696018]        [&lt;ffffffffa02c8c79&gt;] handle_cmd+0x49/0xe0 [tipc]
[  327.696018]        [&lt;ffffffff8143e898&gt;] genl_family_rcv_msg+0x268/0x340
[  327.696018]        [&lt;ffffffff8143ed30&gt;] genl_rcv_msg+0x70/0xd0
[  327.696018]        [&lt;ffffffff8143d4c9&gt;] netlink_rcv_skb+0x89/0xb0
[  327.696018]        [&lt;ffffffff8143e617&gt;] genl_rcv+0x27/0x40
[  327.696018]        [&lt;ffffffff8143d21e&gt;] netlink_unicast+0x15e/0x1b0
[  327.696018]        [&lt;ffffffff8143ddcf&gt;] netlink_sendmsg+0x22f/0x400
[  327.696018]        [&lt;ffffffff813f7836&gt;] __sock_sendmsg+0x66/0x80
[  327.696018]        [&lt;ffffffff813f7957&gt;] sock_aio_write+0x107/0x120
[  327.696018]        [&lt;ffffffff8117f76d&gt;] do_sync_write+0x7d/0xc0
[  327.696018]        [&lt;ffffffff8117fc56&gt;] vfs_write+0x186/0x190
[  327.696018]        [&lt;ffffffff811803e0&gt;] SyS_write+0x60/0xb0
[  327.696018]        [&lt;ffffffff814de852&gt;] system_call_fastpath+0x16/0x1b
[  327.696018]
[  327.696018] other info that might help us debug this:
[  327.696018]
[  327.696018]  Possible unsafe locking scenario:
[  327.696018]
[  327.696018]        CPU0                    CPU1
[  327.696018]        ----                    ----
[  327.696018]   lock(&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock);
[  327.696018]                                lock(((timer))#2);
[  327.696018]                                lock(&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock);
[  327.696018]   lock(((timer))#2);
[  327.696018]
[  327.696018]  *** DEADLOCK ***
[  327.696018]
[  327.696018] 5 locks held by tipc-config/5825:
[  327.696018]  #0:  (cb_lock){++++++}, at: [&lt;ffffffff8143e608&gt;] genl_rcv+0x18/0x40
[  327.696018]  #1:  (genl_mutex){+.+.+.}, at: [&lt;ffffffff8143ed66&gt;] genl_rcv_msg+0xa6/0xd0
[  327.696018]  #2:  (config_mutex){+.+.+.}, at: [&lt;ffffffffa02bf889&gt;] tipc_cfg_do_cmd+0x39/ 0x550 [tipc]
[  327.696018]  #3:  (tipc_net_lock){++.-..}, at: [&lt;ffffffffa02be738&gt;] tipc_disable_bearer+ 0x18/0x60 [tipc]
[  327.696018]  #4:  (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}, at: [&lt;ffffffffa02be58d&gt;]             bearer_disable+0xdd/0x120 [tipc]
[  327.696018]
[  327.696018] stack backtrace:
[  327.696018] CPU: 2 PID: 5825 Comm: tipc-config Tainted: G           O 3.11.0-rc3-wwd-    default #4
[  327.696018] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
[  327.696018]  00000000ffffffff ffff880037fa77a8 ffffffff814d03dd 0000000000000000
[  327.696018]  ffff880037fa7808 ffff880037fa77e8 ffffffff810b1c4f 0000000037fa77e8
[  327.696018]  ffff880037fa7808 ffff880037e4db40 0000000000000000 ffff880037e4e318
[  327.696018] Call Trace:
[  327.696018]  [&lt;ffffffff814d03dd&gt;] dump_stack+0x4d/0xa0
[  327.696018]  [&lt;ffffffff810b1c4f&gt;] print_circular_bug+0x10f/0x120
[  327.696018]  [&lt;ffffffff810b33fe&gt;] check_prev_add+0x43e/0x4b0
[  327.696018]  [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]  [&lt;ffffffff81087a28&gt;] ? sched_clock_cpu+0xd8/0x110
[  327.696018]  [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]  [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]  [&lt;ffffffff8105be80&gt;] ? try_to_del_timer_sync+0x70/0x70
[  327.696018]  [&lt;ffffffff8105bebd&gt;] del_timer_sync+0x3d/0xd0
[  327.696018]  [&lt;ffffffff8105be80&gt;] ? try_to_del_timer_sync+0x70/0x70
[  327.696018]  [&lt;ffffffffa02c5855&gt;] tipc_disc_delete+0x15/0x30 [tipc]
[  327.696018]  [&lt;ffffffffa02be59f&gt;] bearer_disable+0xef/0x120 [tipc]
[  327.696018]  [&lt;ffffffffa02be74f&gt;] tipc_disable_bearer+0x2f/0x60 [tipc]
[  327.696018]  [&lt;ffffffffa02bfb32&gt;] tipc_cfg_do_cmd+0x2e2/0x550 [tipc]
[  327.696018]  [&lt;ffffffff81218783&gt;] ? security_capable+0x13/0x20
[  327.696018]  [&lt;ffffffffa02c8c79&gt;] handle_cmd+0x49/0xe0 [tipc]
[  327.696018]  [&lt;ffffffff8143e898&gt;] genl_family_rcv_msg+0x268/0x340
[  327.696018]  [&lt;ffffffff8143ed30&gt;] genl_rcv_msg+0x70/0xd0
[  327.696018]  [&lt;ffffffff8143ecc0&gt;] ? genl_lock+0x20/0x20
[  327.696018]  [&lt;ffffffff8143d4c9&gt;] netlink_rcv_skb+0x89/0xb0
[  327.696018]  [&lt;ffffffff8143e608&gt;] ? genl_rcv+0x18/0x40
[  327.696018]  [&lt;ffffffff8143e617&gt;] genl_rcv+0x27/0x40
[  327.696018]  [&lt;ffffffff8143d21e&gt;] netlink_unicast+0x15e/0x1b0
[  327.696018]  [&lt;ffffffff81289d7c&gt;] ? memcpy_fromiovec+0x6c/0x90
[  327.696018]  [&lt;ffffffff8143ddcf&gt;] netlink_sendmsg+0x22f/0x400
[  327.696018]  [&lt;ffffffff813f7836&gt;] __sock_sendmsg+0x66/0x80
[  327.696018]  [&lt;ffffffff813f7957&gt;] sock_aio_write+0x107/0x120
[  327.696018]  [&lt;ffffffff813fe29c&gt;] ? release_sock+0x8c/0xa0
[  327.696018]  [&lt;ffffffff8117f76d&gt;] do_sync_write+0x7d/0xc0
[  327.696018]  [&lt;ffffffff8117fa24&gt;] ? rw_verify_area+0x54/0x100
[  327.696018]  [&lt;ffffffff8117fc56&gt;] vfs_write+0x186/0x190
[  327.696018]  [&lt;ffffffff811803e0&gt;] SyS_write+0x60/0xb0
[  327.696018]  [&lt;ffffffff814de852&gt;] system_call_fastpath+0x16/0x1b

-----------------------------------------------------------------------

The problem is that the tipc_link_delete() will cancel the timer disc_timeout() when
the b_ptr-&gt;lock is hold, but the disc_timeout() still call b_ptr-&gt;lock to finish the
work, so the dead lock occurs.

We should unlock the b_ptr-&gt;lock when del the disc_timeout().

Remove link_timeout() still met the same problem, the patch:

http://article.gmane.org/gmane.network.tipc.general/4380

fix the problem, so no need to send patch for fix link_timeout() deadlock warming.

Signed-off-by: Wang Weidong &lt;wangweidong1@huawei.com&gt;
Signed-off-by: Ding Tianhong &lt;dingtianhong@huawei.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We met lockdep warning when enable and disable the bearer for commands such as:

tipc-config -netid=1234 -addr=1.1.3 -be=eth:eth0
tipc-config -netid=1234 -addr=1.1.3 -bd=eth:eth0

---------------------------------------------------

[  327.693595] ======================================================
[  327.693994] [ INFO: possible circular locking dependency detected ]
[  327.694519] 3.11.0-rc3-wwd-default #4 Tainted: G           O
[  327.694882] -------------------------------------------------------
[  327.695385] tipc-config/5825 is trying to acquire lock:
[  327.695754]  (((timer))#2){+.-...}, at: [&lt;ffffffff8105be80&gt;] del_timer_sync+0x0/0xd0
[  327.696018]
[  327.696018] but task is already holding lock:
[  327.696018]  (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}, at: [&lt;ffffffffa02be58d&gt;] bearer_disable+  0xdd/0x120 [tipc]
[  327.696018]
[  327.696018] which lock already depends on the new lock.
[  327.696018]
[  327.696018]
[  327.696018] the existing dependency chain (in reverse order) is:
[  327.696018]
[  327.696018] -&gt; #1 (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}:
[  327.696018]        [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]        [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]        [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]        [&lt;ffffffff814d65b1&gt;] _raw_spin_lock_bh+0x41/0x80
[  327.696018]        [&lt;ffffffffa02c5d48&gt;] disc_timeout+0x18/0xd0 [tipc]
[  327.696018]        [&lt;ffffffff8105b92a&gt;] call_timer_fn+0xda/0x1e0
[  327.696018]        [&lt;ffffffff8105bcd7&gt;] run_timer_softirq+0x2a7/0x2d0
[  327.696018]        [&lt;ffffffff8105379a&gt;] __do_softirq+0x16a/0x2e0
[  327.696018]        [&lt;ffffffff81053a35&gt;] irq_exit+0xd5/0xe0
[  327.696018]        [&lt;ffffffff81033005&gt;] smp_apic_timer_interrupt+0x45/0x60
[  327.696018]        [&lt;ffffffff814df4af&gt;] apic_timer_interrupt+0x6f/0x80
[  327.696018]        [&lt;ffffffff8100b70e&gt;] arch_cpu_idle+0x1e/0x30
[  327.696018]        [&lt;ffffffff810a039d&gt;] cpu_idle_loop+0x1fd/0x280
[  327.696018]        [&lt;ffffffff810a043e&gt;] cpu_startup_entry+0x1e/0x20
[  327.696018]        [&lt;ffffffff81031589&gt;] start_secondary+0x89/0x90
[  327.696018]
[  327.696018] -&gt; #0 (((timer))#2){+.-...}:
[  327.696018]        [&lt;ffffffff810b33fe&gt;] check_prev_add+0x43e/0x4b0
[  327.696018]        [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]        [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]        [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]        [&lt;ffffffff8105bebd&gt;] del_timer_sync+0x3d/0xd0
[  327.696018]        [&lt;ffffffffa02c5855&gt;] tipc_disc_delete+0x15/0x30 [tipc]
[  327.696018]        [&lt;ffffffffa02be59f&gt;] bearer_disable+0xef/0x120 [tipc]
[  327.696018]        [&lt;ffffffffa02be74f&gt;] tipc_disable_bearer+0x2f/0x60 [tipc]
[  327.696018]        [&lt;ffffffffa02bfb32&gt;] tipc_cfg_do_cmd+0x2e2/0x550 [tipc]
[  327.696018]        [&lt;ffffffffa02c8c79&gt;] handle_cmd+0x49/0xe0 [tipc]
[  327.696018]        [&lt;ffffffff8143e898&gt;] genl_family_rcv_msg+0x268/0x340
[  327.696018]        [&lt;ffffffff8143ed30&gt;] genl_rcv_msg+0x70/0xd0
[  327.696018]        [&lt;ffffffff8143d4c9&gt;] netlink_rcv_skb+0x89/0xb0
[  327.696018]        [&lt;ffffffff8143e617&gt;] genl_rcv+0x27/0x40
[  327.696018]        [&lt;ffffffff8143d21e&gt;] netlink_unicast+0x15e/0x1b0
[  327.696018]        [&lt;ffffffff8143ddcf&gt;] netlink_sendmsg+0x22f/0x400
[  327.696018]        [&lt;ffffffff813f7836&gt;] __sock_sendmsg+0x66/0x80
[  327.696018]        [&lt;ffffffff813f7957&gt;] sock_aio_write+0x107/0x120
[  327.696018]        [&lt;ffffffff8117f76d&gt;] do_sync_write+0x7d/0xc0
[  327.696018]        [&lt;ffffffff8117fc56&gt;] vfs_write+0x186/0x190
[  327.696018]        [&lt;ffffffff811803e0&gt;] SyS_write+0x60/0xb0
[  327.696018]        [&lt;ffffffff814de852&gt;] system_call_fastpath+0x16/0x1b
[  327.696018]
[  327.696018] other info that might help us debug this:
[  327.696018]
[  327.696018]  Possible unsafe locking scenario:
[  327.696018]
[  327.696018]        CPU0                    CPU1
[  327.696018]        ----                    ----
[  327.696018]   lock(&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock);
[  327.696018]                                lock(((timer))#2);
[  327.696018]                                lock(&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock);
[  327.696018]   lock(((timer))#2);
[  327.696018]
[  327.696018]  *** DEADLOCK ***
[  327.696018]
[  327.696018] 5 locks held by tipc-config/5825:
[  327.696018]  #0:  (cb_lock){++++++}, at: [&lt;ffffffff8143e608&gt;] genl_rcv+0x18/0x40
[  327.696018]  #1:  (genl_mutex){+.+.+.}, at: [&lt;ffffffff8143ed66&gt;] genl_rcv_msg+0xa6/0xd0
[  327.696018]  #2:  (config_mutex){+.+.+.}, at: [&lt;ffffffffa02bf889&gt;] tipc_cfg_do_cmd+0x39/ 0x550 [tipc]
[  327.696018]  #3:  (tipc_net_lock){++.-..}, at: [&lt;ffffffffa02be738&gt;] tipc_disable_bearer+ 0x18/0x60 [tipc]
[  327.696018]  #4:  (&amp;(&amp;b_ptr-&gt;lock)-&gt;rlock){+.-...}, at: [&lt;ffffffffa02be58d&gt;]             bearer_disable+0xdd/0x120 [tipc]
[  327.696018]
[  327.696018] stack backtrace:
[  327.696018] CPU: 2 PID: 5825 Comm: tipc-config Tainted: G           O 3.11.0-rc3-wwd-    default #4
[  327.696018] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
[  327.696018]  00000000ffffffff ffff880037fa77a8 ffffffff814d03dd 0000000000000000
[  327.696018]  ffff880037fa7808 ffff880037fa77e8 ffffffff810b1c4f 0000000037fa77e8
[  327.696018]  ffff880037fa7808 ffff880037e4db40 0000000000000000 ffff880037e4e318
[  327.696018] Call Trace:
[  327.696018]  [&lt;ffffffff814d03dd&gt;] dump_stack+0x4d/0xa0
[  327.696018]  [&lt;ffffffff810b1c4f&gt;] print_circular_bug+0x10f/0x120
[  327.696018]  [&lt;ffffffff810b33fe&gt;] check_prev_add+0x43e/0x4b0
[  327.696018]  [&lt;ffffffff810b3b4d&gt;] validate_chain+0x6dd/0x870
[  327.696018]  [&lt;ffffffff81087a28&gt;] ? sched_clock_cpu+0xd8/0x110
[  327.696018]  [&lt;ffffffff810b40bb&gt;] __lock_acquire+0x3db/0x670
[  327.696018]  [&lt;ffffffff810b4453&gt;] lock_acquire+0x103/0x130
[  327.696018]  [&lt;ffffffff8105be80&gt;] ? try_to_del_timer_sync+0x70/0x70
[  327.696018]  [&lt;ffffffff8105bebd&gt;] del_timer_sync+0x3d/0xd0
[  327.696018]  [&lt;ffffffff8105be80&gt;] ? try_to_del_timer_sync+0x70/0x70
[  327.696018]  [&lt;ffffffffa02c5855&gt;] tipc_disc_delete+0x15/0x30 [tipc]
[  327.696018]  [&lt;ffffffffa02be59f&gt;] bearer_disable+0xef/0x120 [tipc]
[  327.696018]  [&lt;ffffffffa02be74f&gt;] tipc_disable_bearer+0x2f/0x60 [tipc]
[  327.696018]  [&lt;ffffffffa02bfb32&gt;] tipc_cfg_do_cmd+0x2e2/0x550 [tipc]
[  327.696018]  [&lt;ffffffff81218783&gt;] ? security_capable+0x13/0x20
[  327.696018]  [&lt;ffffffffa02c8c79&gt;] handle_cmd+0x49/0xe0 [tipc]
[  327.696018]  [&lt;ffffffff8143e898&gt;] genl_family_rcv_msg+0x268/0x340
[  327.696018]  [&lt;ffffffff8143ed30&gt;] genl_rcv_msg+0x70/0xd0
[  327.696018]  [&lt;ffffffff8143ecc0&gt;] ? genl_lock+0x20/0x20
[  327.696018]  [&lt;ffffffff8143d4c9&gt;] netlink_rcv_skb+0x89/0xb0
[  327.696018]  [&lt;ffffffff8143e608&gt;] ? genl_rcv+0x18/0x40
[  327.696018]  [&lt;ffffffff8143e617&gt;] genl_rcv+0x27/0x40
[  327.696018]  [&lt;ffffffff8143d21e&gt;] netlink_unicast+0x15e/0x1b0
[  327.696018]  [&lt;ffffffff81289d7c&gt;] ? memcpy_fromiovec+0x6c/0x90
[  327.696018]  [&lt;ffffffff8143ddcf&gt;] netlink_sendmsg+0x22f/0x400
[  327.696018]  [&lt;ffffffff813f7836&gt;] __sock_sendmsg+0x66/0x80
[  327.696018]  [&lt;ffffffff813f7957&gt;] sock_aio_write+0x107/0x120
[  327.696018]  [&lt;ffffffff813fe29c&gt;] ? release_sock+0x8c/0xa0
[  327.696018]  [&lt;ffffffff8117f76d&gt;] do_sync_write+0x7d/0xc0
[  327.696018]  [&lt;ffffffff8117fa24&gt;] ? rw_verify_area+0x54/0x100
[  327.696018]  [&lt;ffffffff8117fc56&gt;] vfs_write+0x186/0x190
[  327.696018]  [&lt;ffffffff811803e0&gt;] SyS_write+0x60/0xb0
[  327.696018]  [&lt;ffffffff814de852&gt;] system_call_fastpath+0x16/0x1b

-----------------------------------------------------------------------

The problem is that the tipc_link_delete() will cancel the timer disc_timeout() when
the b_ptr-&gt;lock is hold, but the disc_timeout() still call b_ptr-&gt;lock to finish the
work, so the dead lock occurs.

We should unlock the b_ptr-&gt;lock when del the disc_timeout().

Remove link_timeout() still met the same problem, the patch:

http://article.gmane.org/gmane.network.tipc.general/4380

fix the problem, so no need to send patch for fix link_timeout() deadlock warming.

Signed-off-by: Wang Weidong &lt;wangweidong1@huawei.com&gt;
Signed-off-by: Ding Tianhong &lt;dingtianhong@huawei.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tipc: fix oops when creating server socket fails</title>
<updated>2013-08-01T22:54:33+00:00</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2013-08-01T12:29:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=c756891a4e1c08c43780e17aca1d2b849ef31d1a'/>
<id>c756891a4e1c08c43780e17aca1d2b849ef31d1a</id>
<content type='text'>
When creation of TIPC internal server socket fails,
we get an oops with the following dump:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
IP: [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
PGD 13719067 PUD 12008067 PMD 0
Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
Modules linked in: tipc(+)
CPU: 4 PID: 4340 Comm: insmod Not tainted 3.10.0+ #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
task: ffff880014360000 ti: ffff88001374c000 task.ti: ffff88001374c000
RIP: 0010:[&lt;ffffffffa0011f49&gt;]  [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
RSP: 0018:ffff88001374dc98  EFLAGS: 00010292
RAX: 0000000000000000 RBX: ffff880012ac09d8 RCX: 0000000000000000
RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffff880014360000
RBP: ffff88001374dcb8 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0016fa0
R13: ffffffffa0017010 R14: ffffffffa0017010 R15: ffff880012ac09d8
FS:  0000000000000000(0000) GS:ffff880016600000(0063) knlGS:00000000f76668d0
CS:  0010 DS: 002b ES: 002b CR0: 000000008005003b
CR2: 0000000000000020 CR3: 0000000012227000 CR4: 00000000000006e0
Stack:
ffff88001374dcb8 ffffffffa0016fa0 0000000000000000 0000000000000001
ffff88001374dcf8 ffffffffa0012922 ffff88001374dce8 00000000ffffffea
ffffffffa0017100 0000000000000000 ffff8800134241a8 ffffffffa0017150
Call Trace:
[&lt;ffffffffa0012922&gt;] tipc_server_stop+0xa2/0x1b0 [tipc]
[&lt;ffffffffa0009995&gt;] tipc_subscr_stop+0x15/0x20 [tipc]
[&lt;ffffffffa00130f5&gt;] tipc_core_stop+0x1d/0x33 [tipc]
[&lt;ffffffffa001f0d4&gt;] tipc_init+0xd4/0xf8 [tipc]
[&lt;ffffffffa001f000&gt;] ? 0xffffffffa001efff
[&lt;ffffffff8100023f&gt;] do_one_initcall+0x3f/0x150
[&lt;ffffffff81082f4d&gt;] ? __blocking_notifier_call_chain+0x7d/0xd0
[&lt;ffffffff810cc58a&gt;] load_module+0x11aa/0x19c0
[&lt;ffffffff810c8d60&gt;] ? show_initstate+0x50/0x50
[&lt;ffffffff8190311c&gt;] ? retint_restore_args+0xe/0xe
[&lt;ffffffff810cce79&gt;] SyS_init_module+0xd9/0x110
[&lt;ffffffff8190dc65&gt;] sysenter_dispatch+0x7/0x1f
Code: 6c 24 70 4c 89 ef e8 b7 04 8f e1 8b 73 04 4c 89 e7 e8 7c 9e 32 e1 41 83 ac 24
b8 00 00 00 01 4c 89 ef e8 eb 0a 8f e1 48 8b 43 08 &lt;4c&gt; 8b 68 20 4d 8d a5 48 03 00
00 4c 89 e7 e8 04 05 8f e1 4c 89
RIP  [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
RSP &lt;ffff88001374dc98&gt;
CR2: 0000000000000020
---[ end trace b02321f40e4269a3 ]---

We have the following call chain:

tipc_core_start()
    ret = tipc_subscr_start()
        ret = tipc_server_start(){
                  server-&gt;enabled = 1;
                  ret = tipc_open_listening_sock()
              }

I.e., the server-&gt;enabled flag is unconditionally set to 1, whatever
the return value of tipc_open_listening_sock().

This causes a crash when tipc_core_start() tries to clean up
resources after a failed initialization:

    if (ret == failed)
        tipc_subscr_stop()
            tipc_server_stop(){
                if (server-&gt;enabled)
                    tipc_close_conn(){
                        NULL reference of con-&gt;sock-sk
                        OOPS!
                }
            }

To avoid this, tipc_server_start() should only set server-&gt;enabled
to 1 in case of a succesful socket creation. In case of failure, it
should release all allocated resources before returning.

Problem introduced in commit c5fa7b3cf3cb22e4ac60485fc2dc187fe012910f
("tipc: introduce new TIPC server infrastructure") in v3.11-rc1.
Note that it won't be seen often; it takes a module load under memory
constrained conditions in order to trigger the failure condition.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When creation of TIPC internal server socket fails,
we get an oops with the following dump:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
IP: [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
PGD 13719067 PUD 12008067 PMD 0
Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
Modules linked in: tipc(+)
CPU: 4 PID: 4340 Comm: insmod Not tainted 3.10.0+ #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
task: ffff880014360000 ti: ffff88001374c000 task.ti: ffff88001374c000
RIP: 0010:[&lt;ffffffffa0011f49&gt;]  [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
RSP: 0018:ffff88001374dc98  EFLAGS: 00010292
RAX: 0000000000000000 RBX: ffff880012ac09d8 RCX: 0000000000000000
RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffff880014360000
RBP: ffff88001374dcb8 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0016fa0
R13: ffffffffa0017010 R14: ffffffffa0017010 R15: ffff880012ac09d8
FS:  0000000000000000(0000) GS:ffff880016600000(0063) knlGS:00000000f76668d0
CS:  0010 DS: 002b ES: 002b CR0: 000000008005003b
CR2: 0000000000000020 CR3: 0000000012227000 CR4: 00000000000006e0
Stack:
ffff88001374dcb8 ffffffffa0016fa0 0000000000000000 0000000000000001
ffff88001374dcf8 ffffffffa0012922 ffff88001374dce8 00000000ffffffea
ffffffffa0017100 0000000000000000 ffff8800134241a8 ffffffffa0017150
Call Trace:
[&lt;ffffffffa0012922&gt;] tipc_server_stop+0xa2/0x1b0 [tipc]
[&lt;ffffffffa0009995&gt;] tipc_subscr_stop+0x15/0x20 [tipc]
[&lt;ffffffffa00130f5&gt;] tipc_core_stop+0x1d/0x33 [tipc]
[&lt;ffffffffa001f0d4&gt;] tipc_init+0xd4/0xf8 [tipc]
[&lt;ffffffffa001f000&gt;] ? 0xffffffffa001efff
[&lt;ffffffff8100023f&gt;] do_one_initcall+0x3f/0x150
[&lt;ffffffff81082f4d&gt;] ? __blocking_notifier_call_chain+0x7d/0xd0
[&lt;ffffffff810cc58a&gt;] load_module+0x11aa/0x19c0
[&lt;ffffffff810c8d60&gt;] ? show_initstate+0x50/0x50
[&lt;ffffffff8190311c&gt;] ? retint_restore_args+0xe/0xe
[&lt;ffffffff810cce79&gt;] SyS_init_module+0xd9/0x110
[&lt;ffffffff8190dc65&gt;] sysenter_dispatch+0x7/0x1f
Code: 6c 24 70 4c 89 ef e8 b7 04 8f e1 8b 73 04 4c 89 e7 e8 7c 9e 32 e1 41 83 ac 24
b8 00 00 00 01 4c 89 ef e8 eb 0a 8f e1 48 8b 43 08 &lt;4c&gt; 8b 68 20 4d 8d a5 48 03 00
00 4c 89 e7 e8 04 05 8f e1 4c 89
RIP  [&lt;ffffffffa0011f49&gt;] tipc_close_conn+0x59/0xb0 [tipc]
RSP &lt;ffff88001374dc98&gt;
CR2: 0000000000000020
---[ end trace b02321f40e4269a3 ]---

We have the following call chain:

tipc_core_start()
    ret = tipc_subscr_start()
        ret = tipc_server_start(){
                  server-&gt;enabled = 1;
                  ret = tipc_open_listening_sock()
              }

I.e., the server-&gt;enabled flag is unconditionally set to 1, whatever
the return value of tipc_open_listening_sock().

This causes a crash when tipc_core_start() tries to clean up
resources after a failed initialization:

    if (ret == failed)
        tipc_subscr_stop()
            tipc_server_stop(){
                if (server-&gt;enabled)
                    tipc_close_conn(){
                        NULL reference of con-&gt;sock-sk
                        OOPS!
                }
            }

To avoid this, tipc_server_start() should only set server-&gt;enabled
to 1 in case of a succesful socket creation. In case of failure, it
should release all allocated resources before returning.

Problem introduced in commit c5fa7b3cf3cb22e4ac60485fc2dc187fe012910f
("tipc: introduce new TIPC server infrastructure") in v3.11-rc1.
Note that it won't be seen often; it takes a module load under memory
constrained conditions in order to trigger the failure condition.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
</feed>
