<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/net/tipc/server.c, branch v4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-06-27T13:56:58Z</updated>
<entry>
<title>tipc: Use kmemdup instead of kmalloc and memcpy</title>
<updated>2016-06-27T13:56:58Z</updated>
<author>
<name>Amitoj Kaur Chawla</name>
<email>amitoj1606@gmail.com</email>
</author>
<published>2016-06-23T04:49:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=810bf11033637a2069952afb9c37f3afd3bbfe41'/>
<id>urn:sha1:810bf11033637a2069952afb9c37f3afd3bbfe41</id>
<content type='text'>
Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.

The Coccinelle semantic patch used to make this change is as follows:
@@
expression from,to,size,flag;
statement S;
@@

-  to = \(kmalloc\|kzalloc\)(size,flag);
+  to = kmemdup(from,size,flag);
   if (to==NULL || ...) S
-  memcpy(to, from, size);

Signed-off-by: Amitoj Kaur Chawla &lt;amitoj1606@gmail.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: block BH in TCP callbacks</title>
<updated>2016-05-19T18:36:49Z</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2016-05-18T00:44:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b91083a45e4c41b8c952cf02ceb0ce16f0b1b9b1'/>
<id>urn:sha1:b91083a45e4c41b8c952cf02ceb0ce16f0b1b9b1</id>
<content type='text'>
TCP stack can now run from process context.

Use read_lock_bh(&amp;sk-&gt;sk_callback_lock) variant to restore previous
assumption.

Fixes: 5413d1babe8f ("net: do not block BH while processing socket backlog")
Fixes: d41a69f1d390 ("tcp: make tcp_sendmsg() aware of socket backlog")
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Cc: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: fix a race condition leading to subscriber refcnt bug</title>
<updated>2016-04-14T20:46:46Z</updated>
<author>
<name>Parthasarathy Bhuvaragan</name>
<email>parthasarathy.bhuvaragan@ericsson.com</email>
</author>
<published>2016-04-12T11:05:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=333f796235a52727db7e0a13888045f3aa3d5335'/>
<id>urn:sha1:333f796235a52727db7e0a13888045f3aa3d5335</id>
<content type='text'>
Until now, the requests sent to topology server are queued
to a workqueue by the generic server framework.
These messages are processed by worker threads and trigger the
registered callbacks.
To reduce latency on uniprocessor systems, explicit rescheduling
is performed using cond_resched() after MAX_RECV_MSG_COUNT(25)
messages.

This implementation on SMP systems leads to an subscriber refcnt
error as described below:
When a worker thread yields by calling cond_resched() in a SMP
system, a new worker is created on another CPU to process the
pending workitem. Sometimes the sleeping thread wakes up before
the new thread finishes execution.
This breaks the assumption on ordering and being single threaded.
The fault is more frequent when MAX_RECV_MSG_COUNT is lowered.

If the first thread was processing subscription create and the
second thread processing close(), the close request will free
the subscriber and the create request oops as follows:

[31.224137] WARNING: CPU: 2 PID: 266 at include/linux/kref.h:46 tipc_subscrb_rcv_cb+0x317/0x380         [tipc]
[31.228143] CPU: 2 PID: 266 Comm: kworker/u8:1 Not tainted 4.5.0+ #97
[31.228377] Workqueue: tipc_rcv tipc_recv_work [tipc]
[...]
[31.228377] Call Trace:
[31.228377]  [&lt;ffffffff812fbb6b&gt;] dump_stack+0x4d/0x72
[31.228377]  [&lt;ffffffff8105a311&gt;] __warn+0xd1/0xf0
[31.228377]  [&lt;ffffffff8105a3fd&gt;] warn_slowpath_null+0x1d/0x20
[31.228377]  [&lt;ffffffffa0098067&gt;] tipc_subscrb_rcv_cb+0x317/0x380 [tipc]
[31.228377]  [&lt;ffffffffa00a4984&gt;] tipc_receive_from_sock+0xd4/0x130 [tipc]
[31.228377]  [&lt;ffffffffa00a439b&gt;] tipc_recv_work+0x2b/0x50 [tipc]
[31.228377]  [&lt;ffffffff81071925&gt;] process_one_work+0x145/0x3d0
[31.246554] ---[ end trace c3882c9baa05a4fd ]---
[31.248327] BUG: spinlock bad magic on CPU#2, kworker/u8:1/266
[31.249119] BUG: unable to handle kernel NULL pointer dereference at 0000000000000428
[31.249323] IP: [&lt;ffffffff81099d0c&gt;] spin_dump+0x5c/0xe0
[31.249323] PGD 0
[31.249323] Oops: 0000 [#1] SMP

In this commit, we
- rename tipc_conn_shutdown() to tipc_conn_release().
- move connection release callback execution from tipc_close_conn()
  to a new function tipc_sock_release(), which is executed before
  we free the connection.
Thus we release the subscriber during connection release procedure
rather than connection shutdown procedure.

Signed-off-by: Parthasarathy Bhuvaragan &lt;parthasarathy.bhuvaragan@ericsson.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: use alloc_ordered_workqueue() instead of WQ_UNBOUND w/ max_active = 1</title>
<updated>2016-02-06T08:41:58Z</updated>
<author>
<name>Parthasarathy Bhuvaragan</name>
<email>parthasarathy.bhuvaragan@ericsson.com</email>
</author>
<published>2016-02-02T09:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=06c8581f85e99bbf69723f76ad2a40fa8a8c8cdd'/>
<id>urn:sha1:06c8581f85e99bbf69723f76ad2a40fa8a8c8cdd</id>
<content type='text'>
Until now, tipc_rcv and tipc_send workqueues in server are allocated
with parameters WQ_UNBOUND &amp; max_active = 1.
This parameters passed to this function makes it equivalent to
alloc_ordered_workqueue(). The later form is more explicit and
can inherit future ordered_workqueue changes.

In this commit we replace alloc_workqueue() with more readable
alloc_ordered_workqueue().

Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: Parthasarathy Bhuvaragan &lt;parthasarathy.bhuvaragan@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: use sock_create_kern interface to create kernel socket</title>
<updated>2015-05-14T17:39:33Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-05-13T03:20:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fa787ae0624c46d0c894c19ae74f53d7bb4406f8'/>
<id>urn:sha1:fa787ae0624c46d0c894c19ae74f53d7bb4406f8</id>
<content type='text'>
After commit eeb1bd5c40ed ("net: Add a struct net parameter to
sock_create_kern"), we should use sock_create_kern() to create kernel
socket as the interface doesn't reference count struct net any more.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: deal with return value of tipc_conn_new callback</title>
<updated>2015-05-04T19:04:01Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-05-04T02:36:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=90bdfcb76f7d3b4a763ded3242277578ef22eda4'/>
<id>urn:sha1:90bdfcb76f7d3b4a763ded3242277578ef22eda4</id>
<content type='text'>
Once tipc_conn_new() returns NULL, the connection should be shut
down immediately, otherwise, oops may happen due to the NULL pointer.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: fix topology server broken issue</title>
<updated>2015-04-23T15:50:34Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-04-23T13:37:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=def81f69bfbd70a3278a7592a4ab8717300cbac1'/>
<id>urn:sha1:def81f69bfbd70a3278a7592a4ab8717300cbac1</id>
<content type='text'>
When a new topology server is launched in a new namespace, its
listening socket is inserted into the "init ns" namespace's socket
hash table rather than the one owned by the new namespace. Although
the socket's namespace is forcedly changed to the new namespace later,
the socket is still stored in the socket hash table of "init ns"
namespace. When a client created in the new namespace connects
its own topology server, the connection is failed as its server's
socket could not be found from its own namespace's socket table.

If __sock_create() instead of original sock_create_kern() is used
to create the server's socket through specifying an expected namesapce,
the socket will be inserted into the specified namespace's socket
table, thereby avoiding to the topology server broken issue.

Fixes: 76100a8a64bc ("tipc: fix netns refcnt leak")

Reported-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
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: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: withdraw tipc topology server name when namespace is deleted</title>
<updated>2015-03-18T02:11:26Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-03-18T01:32:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b9bb7f338502d9d01543daa9fdf4a7f104bd572'/>
<id>urn:sha1:2b9bb7f338502d9d01543daa9fdf4a7f104bd572</id>
<content type='text'>
The TIPC topology server is a per namespace service associated with the
tipc name {1, 1}. When a namespace is deleted, that name must be withdrawn
before we call sk_release_kernel because the kernel socket release is
done in init_net and trying to withdraw a TIPC name published in another
namespace will fail with an error as:

[  170.093264] Unable to remove local publication
[  170.093264] (type=1, lower=1, ref=2184244004, key=2184244005)

We fix this by breaking the association between the topology server name
and socket before calling sk_release_kernel.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: fix netns refcnt leak</title>
<updated>2015-03-18T02:11:26Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-03-18T01:32:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=76100a8a64bc2ae898bc49d51dd28c1f4f5ed37b'/>
<id>urn:sha1:76100a8a64bc2ae898bc49d51dd28c1f4f5ed37b</id>
<content type='text'>
When the TIPC module is loaded, we launch a topology server in kernel
space, which in its turn is creating TIPC sockets for communication
with topology server users. Because both the socket's creator and
provider reside in the same module, it is necessary that the TIPC
module's reference count remains zero after the server is started and
the socket created; otherwise it becomes impossible to perform "rmmod"
even on an idle module.

Currently, we achieve this by defining a separate "tipc_proto_kern"
protocol struct, that is used only for kernel space socket allocations.
This structure has the "owner" field set to NULL, which restricts the
module reference count from being be bumped when sk_alloc() for local
sockets is called. Furthermore, we have defined three kernel-specific
functions, tipc_sock_create_local(), tipc_sock_release_local() and
tipc_sock_accept_local(), to avoid the module counter being modified
when module local sockets are created or deleted. This has worked well
until we introduced name space support.

However, after name space support was introduced, we have observed that
a reference count leak occurs, because the netns counter is not
decremented in tipc_sock_delete_local().

This commit remedies this problem. But instead of just modifying
tipc_sock_delete_local(), we eliminate the whole parallel socket
handling infrastructure, and start using the regular sk_create_kern(),
kernel_accept() and sk_release_kernel() calls. Since those functions
manipulate the module counter, we must now compensate for that by
explicitly decrementing the counter after module local sockets are
created, and increment it just before calling sk_release_kernel().

Fixes: a62fbccecd62 ("tipc: make subscriber server support net namespace")
Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reported-by: Cong Wang &lt;cwang@twopensource.com&gt;
Tested-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tipc: make subscriber server support net namespace</title>
<updated>2015-01-12T21:24:33Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2015-01-09T07:27:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a62fbccecd62bacb4416fc427239f5b43b25d05e'/>
<id>urn:sha1:a62fbccecd62bacb4416fc427239f5b43b25d05e</id>
<content type='text'>
TIPC establishes one subscriber server which allows users to subscribe
their interesting name service status. After tipc supports namespace,
one dedicated tipc stack instance is created for each namespace, and
each instance can be deemed as one independent TIPC node. As a result,
subscriber server must be built for each namespace.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Tested-by: Tero Aho &lt;Tero.Aho@coriant.com&gt;
Reviewed-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
