<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/net/tipc/socket.c, branch v3.18.40</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.18.40</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.18.40'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2015-09-27T16:18:54Z</updated>
<entry>
<title>net/tipc: initialize security state for new connection socket</title>
<updated>2015-09-27T16:18:54Z</updated>
<author>
<name>Stephen Smalley</name>
<email>sds@tycho.nsa.gov</email>
</author>
<published>2015-07-07T13:43:45Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b558aeea96d34dbcfb3192d0a09f9f80efd4d5a6'/>
<id>urn:sha1:b558aeea96d34dbcfb3192d0a09f9f80efd4d5a6</id>
<content type='text'>
[ Upstream commit fdd75ea8df370f206a8163786e7470c1277a5064 ]

Calling connect() with an AF_TIPC socket would trigger a series
of error messages from SELinux along the lines of:
SELinux: Invalid class 0
type=AVC msg=audit(1434126658.487:34500): avc:  denied  { &lt;unprintable&gt; }
  for pid=292 comm="kworker/u16:5" scontext=system_u:system_r:kernel_t:s0
  tcontext=system_u:object_r:unlabeled_t:s0 tclass=&lt;unprintable&gt;
  permissive=0

This was due to a failure to initialize the security state of the new
connection sock by the tipc code, leaving it with junk in the security
class field and an unlabeled secid.  Add a call to security_sk_clone()
to inherit the security state from the parent socket.

Reported-by: Tim Shearer &lt;tim.shearer@overturenetworks.com&gt;
Signed-off-by: Stephen Smalley &lt;sds@tycho.nsa.gov&gt;
Acked-by: Paul Moore &lt;paul@paul-moore.com&gt;
Acked-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</content>
</entry>
<entry>
<title>tipc: fix lockdep warning when intra-node messages are delivered</title>
<updated>2014-10-21T19:28:15Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2014-10-20T06:46:35Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1a194c2d59c55c37cb4c0c459d5418071a141341'/>
<id>urn:sha1:1a194c2d59c55c37cb4c0c459d5418071a141341</id>
<content type='text'>
When running tipcTC&amp;tipcTS test suite, below lockdep unsafe locking
scenario is reported:

[ 1109.997854]
[ 1109.997988] =================================
[ 1109.998290] [ INFO: inconsistent lock state ]
[ 1109.998575] 3.17.0-rc1+ #113 Not tainted
[ 1109.998762] ---------------------------------
[ 1109.998762] inconsistent {SOFTIRQ-ON-W} -&gt; {IN-SOFTIRQ-W} usage.
[ 1109.998762] swapper/7/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
[ 1109.998762]  (slock-AF_TIPC){+.?...}, at: [&lt;ffffffffa0011969&gt;] tipc_sk_rcv+0x49/0x2b0 [tipc]
[ 1109.998762] {SOFTIRQ-ON-W} state was registered at:
[ 1109.998762]   [&lt;ffffffff810a4770&gt;] __lock_acquire+0x6a0/0x1d80
[ 1109.998762]   [&lt;ffffffff810a6555&gt;] lock_acquire+0x95/0x1e0
[ 1109.998762]   [&lt;ffffffff81a2d1ce&gt;] _raw_spin_lock+0x3e/0x80
[ 1109.998762]   [&lt;ffffffffa0011969&gt;] tipc_sk_rcv+0x49/0x2b0 [tipc]
[ 1109.998762]   [&lt;ffffffffa0004fe8&gt;] tipc_link_xmit+0xa8/0xc0 [tipc]
[ 1109.998762]   [&lt;ffffffffa000ec6f&gt;] tipc_sendmsg+0x15f/0x550 [tipc]
[ 1109.998762]   [&lt;ffffffffa000f165&gt;] tipc_connect+0x105/0x140 [tipc]
[ 1109.998762]   [&lt;ffffffff817676ee&gt;] SYSC_connect+0xae/0xc0
[ 1109.998762]   [&lt;ffffffff81767b7e&gt;] SyS_connect+0xe/0x10
[ 1109.998762]   [&lt;ffffffff817a9788&gt;] compat_SyS_socketcall+0xb8/0x200
[ 1109.998762]   [&lt;ffffffff81a306e5&gt;] sysenter_dispatch+0x7/0x1f
[ 1109.998762] irq event stamp: 241060
[ 1109.998762] hardirqs last  enabled at (241060): [&lt;ffffffff8105a4ad&gt;] __local_bh_enable_ip+0x6d/0xd0
[ 1109.998762] hardirqs last disabled at (241059): [&lt;ffffffff8105a46f&gt;] __local_bh_enable_ip+0x2f/0xd0
[ 1109.998762] softirqs last  enabled at (241020): [&lt;ffffffff81059a52&gt;] _local_bh_enable+0x22/0x50
[ 1109.998762] softirqs last disabled at (241021): [&lt;ffffffff8105a626&gt;] irq_exit+0x96/0xc0
[ 1109.998762]
[ 1109.998762] other info that might help us debug this:
[ 1109.998762]  Possible unsafe locking scenario:
[ 1109.998762]
[ 1109.998762]        CPU0
[ 1109.998762]        ----
[ 1109.998762]   lock(slock-AF_TIPC);
[ 1109.998762]   &lt;Interrupt&gt;
[ 1109.998762]     lock(slock-AF_TIPC);
[ 1109.998762]
[ 1109.998762]  *** DEADLOCK ***
[ 1109.998762]
[ 1109.998762] 2 locks held by swapper/7/0:
[ 1109.998762]  #0:  (rcu_read_lock){......}, at: [&lt;ffffffff81782dc9&gt;] __netif_receive_skb_core+0x69/0xb70
[ 1109.998762]  #1:  (rcu_read_lock){......}, at: [&lt;ffffffffa0001c90&gt;] tipc_l2_rcv_msg+0x40/0x260 [tipc]
[ 1109.998762]
[ 1109.998762] stack backtrace:
[ 1109.998762] CPU: 7 PID: 0 Comm: swapper/7 Not tainted 3.17.0-rc1+ #113
[ 1109.998762] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
[ 1109.998762]  ffffffff82745830 ffff880016c03828 ffffffff81a209eb 0000000000000007
[ 1109.998762]  ffff880017b3cac0 ffff880016c03888 ffffffff81a1c5ef 0000000000000001
[ 1109.998762]  ffff880000000001 ffff880000000000 ffffffff81012d4f 0000000000000000
[ 1109.998762] Call Trace:
[ 1109.998762]  &lt;IRQ&gt;  [&lt;ffffffff81a209eb&gt;] dump_stack+0x4e/0x68
[ 1109.998762]  [&lt;ffffffff81a1c5ef&gt;] print_usage_bug+0x1f1/0x202
[ 1109.998762]  [&lt;ffffffff81012d4f&gt;] ? save_stack_trace+0x2f/0x50
[ 1109.998762]  [&lt;ffffffff810a406c&gt;] mark_lock+0x28c/0x2f0
[ 1109.998762]  [&lt;ffffffff810a3440&gt;] ? print_irq_inversion_bug.part.46+0x1f0/0x1f0
[ 1109.998762]  [&lt;ffffffff810a467d&gt;] __lock_acquire+0x5ad/0x1d80
[ 1109.998762]  [&lt;ffffffff810a70dd&gt;] ? trace_hardirqs_on+0xd/0x10
[ 1109.998762]  [&lt;ffffffff8108ace8&gt;] ? sched_clock_cpu+0x98/0xc0
[ 1109.998762]  [&lt;ffffffff8108ad2b&gt;] ? local_clock+0x1b/0x30
[ 1109.998762]  [&lt;ffffffff810a10dc&gt;] ? lock_release_holdtime.part.29+0x1c/0x1a0
[ 1109.998762]  [&lt;ffffffff8108aa05&gt;] ? sched_clock_local+0x25/0x90
[ 1109.998762]  [&lt;ffffffffa000dec0&gt;] ? tipc_sk_get+0x60/0x80 [tipc]
[ 1109.998762]  [&lt;ffffffff810a6555&gt;] lock_acquire+0x95/0x1e0
[ 1109.998762]  [&lt;ffffffffa0011969&gt;] ? tipc_sk_rcv+0x49/0x2b0 [tipc]
[ 1109.998762]  [&lt;ffffffff810a6fb6&gt;] ? trace_hardirqs_on_caller+0xa6/0x1c0
[ 1109.998762]  [&lt;ffffffff81a2d1ce&gt;] _raw_spin_lock+0x3e/0x80
[ 1109.998762]  [&lt;ffffffffa0011969&gt;] ? tipc_sk_rcv+0x49/0x2b0 [tipc]
[ 1109.998762]  [&lt;ffffffffa000dec0&gt;] ? tipc_sk_get+0x60/0x80 [tipc]
[ 1109.998762]  [&lt;ffffffffa0011969&gt;] tipc_sk_rcv+0x49/0x2b0 [tipc]
[ 1109.998762]  [&lt;ffffffffa00076bd&gt;] tipc_rcv+0x5ed/0x960 [tipc]
[ 1109.998762]  [&lt;ffffffffa0001d1c&gt;] tipc_l2_rcv_msg+0xcc/0x260 [tipc]
[ 1109.998762]  [&lt;ffffffffa0001c90&gt;] ? tipc_l2_rcv_msg+0x40/0x260 [tipc]
[ 1109.998762]  [&lt;ffffffff81783345&gt;] __netif_receive_skb_core+0x5e5/0xb70
[ 1109.998762]  [&lt;ffffffff81782dc9&gt;] ? __netif_receive_skb_core+0x69/0xb70
[ 1109.998762]  [&lt;ffffffff81784eb9&gt;] ? dev_gro_receive+0x259/0x4e0
[ 1109.998762]  [&lt;ffffffff817838f6&gt;] __netif_receive_skb+0x26/0x70
[ 1109.998762]  [&lt;ffffffff81783acd&gt;] netif_receive_skb_internal+0x2d/0x1f0
[ 1109.998762]  [&lt;ffffffff81785518&gt;] napi_gro_receive+0xd8/0x240
[ 1109.998762]  [&lt;ffffffff815bf854&gt;] e1000_clean_rx_irq+0x2c4/0x530
[ 1109.998762]  [&lt;ffffffff815c1a46&gt;] e1000_clean+0x266/0x9c0
[ 1109.998762]  [&lt;ffffffff8108ad2b&gt;] ? local_clock+0x1b/0x30
[ 1109.998762]  [&lt;ffffffff8108aa05&gt;] ? sched_clock_local+0x25/0x90
[ 1109.998762]  [&lt;ffffffff817842b1&gt;] net_rx_action+0x141/0x310
[ 1109.998762]  [&lt;ffffffff810bd710&gt;] ? handle_fasteoi_irq+0xe0/0x150
[ 1109.998762]  [&lt;ffffffff81059fa6&gt;] __do_softirq+0x116/0x4d0
[ 1109.998762]  [&lt;ffffffff8105a626&gt;] irq_exit+0x96/0xc0
[ 1109.998762]  [&lt;ffffffff81a30d07&gt;] do_IRQ+0x67/0x110
[ 1109.998762]  [&lt;ffffffff81a2ee2f&gt;] common_interrupt+0x6f/0x6f
[ 1109.998762]  &lt;EOI&gt;  [&lt;ffffffff8100d2b7&gt;] ? default_idle+0x37/0x250
[ 1109.998762]  [&lt;ffffffff8100d2b5&gt;] ? default_idle+0x35/0x250
[ 1109.998762]  [&lt;ffffffff8100dd1f&gt;] arch_cpu_idle+0xf/0x20
[ 1109.998762]  [&lt;ffffffff810999fd&gt;] cpu_startup_entry+0x27d/0x4d0
[ 1109.998762]  [&lt;ffffffff81034c78&gt;] start_secondary+0x188/0x1f0

When intra-node messages are delivered from one process to another
process, tipc_link_xmit() doesn't disable BH before it directly calls
tipc_sk_rcv() on process context to forward messages to destination
socket. Meanwhile, if messages delivered by remote node arrive at the
node and their destinations are also the same socket, tipc_sk_rcv()
running on process context might be preempted by tipc_sk_rcv() running
BH context. As a result, the latter cannot obtain the socket lock as
the lock was obtained by the former, however, the former has no chance
to be run as the latter is owning the CPU now, so headlock happens. To
avoid it, BH should be always disabled in tipc_sk_rcv().

Signed-off-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;
</content>
</entry>
<entry>
<title>tipc: fix a potential deadlock</title>
<updated>2014-10-21T19:28:15Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2014-10-20T06:44:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7b8613e0a1502b43b3b36c93c66f835c891f63b3'/>
<id>urn:sha1:7b8613e0a1502b43b3b36c93c66f835c891f63b3</id>
<content type='text'>
Locking dependency detected below possible unsafe locking scenario:

           CPU0                          CPU1
T0:  tipc_named_rcv()                tipc_rcv()
T1:  [grab nametble write lock]*     [grab node lock]*
T2:  tipc_update_nametbl()           tipc_node_link_up()
T3:  tipc_nodesub_subscribe()        tipc_nametbl_publish()
T4:  [grab node lock]*               [grab nametble write lock]*

The opposite order of holding nametbl write lock and node lock on
above two different paths may result in a deadlock. If we move the
the updating of the name table after link state named out of node
lock, the reverse order of holding locks will be eliminated, and
as a result, the deadlock risk.

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: fix a potential oops</title>
<updated>2014-08-30T03:22:43Z</updated>
<author>
<name>Ying Xue</name>
<email>ying.xue@windriver.com</email>
</author>
<published>2014-08-28T02:02:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cc086fcf92996965f0dcf05c6641d65381705266'/>
<id>urn:sha1:cc086fcf92996965f0dcf05c6641d65381705266</id>
<content type='text'>
Commit 6c9808ce09f7 ("tipc: remove port_lock") accidentally involves
a potential bug: when tipc socket instance(tsk) is not got with given
reference number in tipc_sk_get(), tsk is set to NULL. Subsequently
we jump to exit label where to decrease socket reference counter
pointed by tsk pointer in tipc_sk_put(). However, As now tsk is NULL,
oops may happen because of touching a NULL pointer.

Signed-off-by: Ying Xue &lt;ying.xue@windriver.com&gt;
Acked-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Acked-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: merge struct tipc_port into struct tipc_sock</title>
<updated>2014-08-23T18:18:35Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=301bae56f21295a4ba71367818d80735687f11ac'/>
<id>urn:sha1:301bae56f21295a4ba71367818d80735687f11ac</id>
<content type='text'>
We complete the merging of the port and socket layer by aggregating
the fields of struct tipc_port directly into struct tipc_sock, and
moving the combined structure into socket.c.

We also move all functions and macros that are not any longer
exposed to the rest of the stack into socket.c, and rename them
accordingly.

Despite the size of this commit, there are no functional changes.
We have only made such changes that are necessary due of the removal
of struct tipc_port.

Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-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: remove files ref.h and ref.c</title>
<updated>2014-08-23T18:18:35Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=808d90f9c55943c2965d33b7156e559c59dd2db9'/>
<id>urn:sha1:808d90f9c55943c2965d33b7156e559c59dd2db9</id>
<content type='text'>
The reference table is now 'socket aware' instead of being generic,
and has in reality become a socket internal table. In order to be
able to minimize the API exposed by the socket layer towards the rest
of the stack, we now move the reference table definitions and functions
into the file socket.c, and rename the functions accordingly.

There are no functional changes in this commit.

Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-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: remove include file port.h</title>
<updated>2014-08-23T18:18:35Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2e84c60b77e4dd96068f568a5971e681bb7e6b68'/>
<id>urn:sha1:2e84c60b77e4dd96068f568a5971e681bb7e6b68</id>
<content type='text'>
We move the inline functions in the file port.h to socket.c, and modify
their names accordingly.

We move struct tipc_port and some macros to socket.h.

Finally, we remove the file port.h.

Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-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: remove source file port.c</title>
<updated>2014-08-23T18:18:35Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0fc87aaebdfbf2c75112ce17aec093652c682acd'/>
<id>urn:sha1:0fc87aaebdfbf2c75112ce17aec093652c682acd</id>
<content type='text'>
In this commit, we move the remaining functions in port.c to
socket.c, and give them new names that correspond to their new
location. We then remove the file port.c.

There are only cosmetic changes to the moved functions.

Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-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: remove port_lock</title>
<updated>2014-08-23T18:18:34Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6c9808ce09f778a1de7b207b82cfc36a59cda2d3'/>
<id>urn:sha1:6c9808ce09f778a1de7b207b82cfc36a59cda2d3</id>
<content type='text'>
In previous commits we have reduced usage of port_lock to a minimum,
and complemented it with usage of bh_lock_sock() at the remaining
locations. The purpose has been to remove this lock altogether, since
it largely duplicates the role of bh_lock_sock. We are now ready to do
this.

However, we still need to protect the BH callers from inadvertent
release of the socket while they hold a reference to it. We do this by
replacing port_lock by a combination of a rw-lock protecting the
reference table as such, and updating the socket reference counter while
the socket is referenced from BH. This technique is more standard and
comprehensible than the previous approach, and turns out to have a
positive effect on overall performance.

Signed-off-by: Jon Maloy &lt;jon.maloy@ericsson.com&gt;
Reviewed-by: Erik Hugne &lt;erik.hugne@ericsson.com&gt;
Reviewed-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: replace port pointer with socket pointer in registry</title>
<updated>2014-08-23T18:18:34Z</updated>
<author>
<name>Jon Paul Maloy</name>
<email>jon.maloy@ericsson.com</email>
</author>
<published>2014-08-22T22:09:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9b50fd087a9f1454d6a8b613fff376dfb6d6ea93'/>
<id>urn:sha1:9b50fd087a9f1454d6a8b613fff376dfb6d6ea93</id>
<content type='text'>
In order to make tipc_sock the only entity referencable from other
parts of the stack, we add a tipc_sock pointer instead of a tipc_port
pointer to the registry. As a consequence, we also let the function
tipc_port_lock() return a pointer to a tipc_sock instead  of a tipc_port.
We keep the function's name for now, since the lock still is owned by
the port.

This is another step in the direction of eliminating port_lock, replacing
its usage with lock_sock() and bh_lock_sock().

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