<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/rds/send.c, branch linux-4.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-04-19T06:54:04Z</updated>
<entry>
<title>rds: MP-RDS may use an invalid c_path</title>
<updated>2018-04-19T06:54:04Z</updated>
<author>
<name>Ka-Cheong Poon</name>
</author>
<published>2018-04-11T07:57:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f46efb79f5d3e6aa4e50942c1fc3c1e05ac6198d'/>
<id>urn:sha1:f46efb79f5d3e6aa4e50942c1fc3c1e05ac6198d</id>
<content type='text'>
[ Upstream commit a43cced9a348901f9015f4730b70b69e7c41a9c9 ]

rds_sendmsg() calls rds_send_mprds_hash() to find a c_path to use to
send a message.  Suppose the RDS connection is not yet up.  In
rds_send_mprds_hash(), it does

	if (conn-&gt;c_npaths == 0)
		wait_event_interruptible(conn-&gt;c_hs_waitq,
					 (conn-&gt;c_npaths != 0));

If it is interrupted before the connection is set up,
rds_send_mprds_hash() will return a non-zero hash value.  Hence
rds_sendmsg() will use a non-zero c_path to send the message.  But if
the RDS connection ends up to be non-MP capable, the message will be
lost as only the zero c_path can be used.

Signed-off-by: Ka-Cheong Poon &lt;ka-cheong.poon@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rds: tcp: use rds_destroy_pending() to synchronize netns/module teardown and rds connection/workq management</title>
<updated>2018-02-08T20:23:52Z</updated>
<author>
<name>Sowmini Varadhan</name>
</author>
<published>2018-02-03T12:26:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ebeeb1ad9b8adcc37c2ec21a96f39e9d35199b46'/>
<id>urn:sha1:ebeeb1ad9b8adcc37c2ec21a96f39e9d35199b46</id>
<content type='text'>
An rds_connection can get added during netns deletion between lines 528
and 529 of

  506 static void rds_tcp_kill_sock(struct net *net)
  :
  /* code to pull out all the rds_connections that should be destroyed */
  :
  528         spin_unlock_irq(&amp;rds_tcp_conn_lock);
  529         list_for_each_entry_safe(tc, _tc, &amp;tmp_list, t_tcp_node)
  530                 rds_conn_destroy(tc-&gt;t_cpath-&gt;cp_conn);

Such an rds_connection would miss out the rds_conn_destroy()
loop (that cancels all pending work) and (if it was scheduled
after netns deletion) could trigger the use-after-free.

A similar race-window exists for the module unload path
in rds_tcp_exit -&gt; rds_tcp_destroy_conns

Concurrency with netns deletion (rds_tcp_kill_sock()) must be handled
by checking check_net() before enqueuing new work or adding new
connections.

Concurrency with module-unload is handled by maintaining a module
specific flag that is set at the start of the module exit function,
and must be checked before enqueuing new work or adding new connections.

This commit refactors existing RDS_DESTROY_PENDING checks added by
commit 3db6e0d172c9 ("rds: use RCU to synchronize work-enqueue with
connection teardown") and consolidates all the concurrency checks
listed above into the function rds_destroy_pending().

Signed-off-by: Sowmini Varadhan &lt;sowmini.varadhan@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: use RCU to synchronize work-enqueue with connection teardown</title>
<updated>2018-01-05T18:39:18Z</updated>
<author>
<name>Sowmini Varadhan</name>
</author>
<published>2018-01-04T14:53:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3db6e0d172c94bd9953a1347c55ffb64b1d2e74f'/>
<id>urn:sha1:3db6e0d172c94bd9953a1347c55ffb64b1d2e74f</id>
<content type='text'>
rds_sendmsg() can enqueue work on cp_send_w from process context, but
it should not enqueue this work if connection teardown  has commenced
(else we risk enquing work after rds_conn_path_destroy() has assumed that
all work has been cancelled/flushed).

Similarly some other functions like rds_cong_queue_updates
and rds_tcp_data_ready are called in softirq context, and may end
up enqueuing work on rds_wq after rds_conn_path_destroy() has assumed
that all workqs are quiesced.

Check the RDS_DESTROY_PENDING bit and use rcu synchronization to avoid
all these races.

Signed-off-by: Sowmini Varadhan &lt;sowmini.varadhan@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>RDS: Check cmsg_len before dereferencing CMSG_DATA</title>
<updated>2017-12-27T15:37:23Z</updated>
<author>
<name>Avinash Repaka</name>
</author>
<published>2017-12-22T04:17:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=14e138a86f6347c6199f610576d2e11c03bec5f0'/>
<id>urn:sha1:14e138a86f6347c6199f610576d2e11c03bec5f0</id>
<content type='text'>
RDS currently doesn't check if the length of the control message is
large enough to hold the required data, before dereferencing the control
message data. This results in following crash:

BUG: KASAN: stack-out-of-bounds in rds_rdma_bytes net/rds/send.c:1013
[inline]
BUG: KASAN: stack-out-of-bounds in rds_sendmsg+0x1f02/0x1f90
net/rds/send.c:1066
Read of size 8 at addr ffff8801c928fb70 by task syzkaller455006/3157

CPU: 0 PID: 3157 Comm: syzkaller455006 Not tainted 4.15.0-rc3+ #161
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x25b/0x340 mm/kasan/report.c:409
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 rds_rdma_bytes net/rds/send.c:1013 [inline]
 rds_sendmsg+0x1f02/0x1f90 net/rds/send.c:1066
 sock_sendmsg_nosec net/socket.c:628 [inline]
 sock_sendmsg+0xca/0x110 net/socket.c:638
 ___sys_sendmsg+0x320/0x8b0 net/socket.c:2018
 __sys_sendmmsg+0x1ee/0x620 net/socket.c:2108
 SYSC_sendmmsg net/socket.c:2139 [inline]
 SyS_sendmmsg+0x35/0x60 net/socket.c:2134
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x43fe49
RSP: 002b:00007fffbe244ad8 EFLAGS: 00000217 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fe49
RDX: 0000000000000001 RSI: 000000002020c000 RDI: 0000000000000003
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000217 R12: 00000000004017b0
R13: 0000000000401840 R14: 0000000000000000 R15: 0000000000000000

To fix this, we verify that the cmsg_len is large enough to hold the
data to be read, before proceeding further.

Reported-by: syzbot &lt;syzkaller-bugs@googlegroups.com&gt;
Signed-off-by: Avinash Repaka &lt;avinash.repaka@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Reviewed-by: Yuval Shaia &lt;yuval.shaia@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: Fix incorrect statistics counting</title>
<updated>2017-09-08T03:07:13Z</updated>
<author>
<name>Håkon Bugge</name>
</author>
<published>2017-09-06T16:35:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=126f760ca94dae77425695f9f9238b731de86e32'/>
<id>urn:sha1:126f760ca94dae77425695f9f9238b731de86e32</id>
<content type='text'>
In rds_send_xmit() there is logic to batch the sends. However, if
another thread has acquired the lock and has incremented the send_gen,
it is considered a race and we yield. The code incrementing the
s_send_lock_queue_raced statistics counter did not count this event
correctly.

This commit counts the race condition correctly.

Changes from v1:
- Removed check for *someone_on_xmit()*
- Fixed incorrect indentation

Signed-off-by: Håkon Bugge &lt;haakon.bugge@oracle.com&gt;
Reviewed-by: Knut Omang &lt;knut.omang@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: Fix non-atomic operation on shared flag variable</title>
<updated>2017-09-05T21:49:49Z</updated>
<author>
<name>Håkon Bugge</name>
</author>
<published>2017-09-05T15:42:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f530f39f5ff97209cc6f1bf66e634685954ad741'/>
<id>urn:sha1:f530f39f5ff97209cc6f1bf66e634685954ad741</id>
<content type='text'>
The bits in m_flags in struct rds_message are used for a plurality of
reasons, and from different contexts. To avoid any missing updates to
m_flags, use the atomic set_bit() instead of the non-atomic equivalent.

Signed-off-by: Håkon Bugge &lt;haakon.bugge@oracle.com&gt;
Reviewed-by: Knut Omang &lt;knut.omang@oracle.com&gt;
Reviewed-by: Wei Lin Guay &lt;wei.lin.guay@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: Make sure updates to cp_send_gen can be observed</title>
<updated>2017-07-20T22:33:01Z</updated>
<author>
<name>Håkon Bugge</name>
</author>
<published>2017-07-20T10:28:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e623a48ee433985f6ca0fb238f0002cc2eccdf53'/>
<id>urn:sha1:e623a48ee433985f6ca0fb238f0002cc2eccdf53</id>
<content type='text'>
cp-&gt;cp_send_gen is treated as a normal variable, although it may be
used by different threads.

This is fixed by using {READ,WRITE}_ONCE when it is incremented and
READ_ONCE when it is read outside the {acquire,release}_in_xmit
protection.

Normative reference from the Linux-Kernel Memory Model:

    Loads from and stores to shared (but non-atomic) variables should
    be protected with the READ_ONCE(), WRITE_ONCE(), and
    ACCESS_ONCE().

Clause 5.1.2.4/25 in the C standard is also relevant.

Signed-off-by: Håkon Bugge &lt;haakon.bugge@oracle.com&gt;
Reviewed-by: Knut Omang &lt;knut.omang@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: tcp: send handshake ping-probe from passive endpoint</title>
<updated>2017-06-22T15:34:04Z</updated>
<author>
<name>Sowmini Varadhan</name>
</author>
<published>2017-06-21T20:40:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=69b92b5b7419846e2a0d61a097b11b17a089e046'/>
<id>urn:sha1:69b92b5b7419846e2a0d61a097b11b17a089e046</id>
<content type='text'>
The RDS handshake ping probe added by commit 5916e2c1554f
("RDS: TCP: Enable multipath RDS for TCP") is sent from rds_sendmsg()
before the first data packet is sent to a peer. If the conversation
is not bidirectional  (i.e., one side is always passive and never
invokes rds_sendmsg()) and the passive side restarts its rds_tcp
module, a new HS ping probe needs to be sent, so that the number
of paths can be re-established.

This patch achieves that by sending a HS ping probe from
rds_tcp_accept_one() when c_npaths is 0 (i.e., we have not done
a handshake probe with this peer yet).

Signed-off-by: Sowmini Varadhan &lt;sowmini.varadhan@oracle.com&gt;
Tested-by: Jenny Xu &lt;jenny.x.xu@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>rds: tcp: various endian-ness fixes</title>
<updated>2017-06-16T16:45:15Z</updated>
<author>
<name>Sowmini Varadhan</name>
</author>
<published>2017-06-15T18:28:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=00354de5779db4aa9c019db787ef89bd1a6b149b'/>
<id>urn:sha1:00354de5779db4aa9c019db787ef89bd1a6b149b</id>
<content type='text'>
Found when testing between sparc and x86 machines on different
subnets, so the address comparison patterns hit the corner cases and
brought out some bugs fixed by this patch.

Signed-off-by: Sowmini Varadhan &lt;sowmini.varadhan@oracle.com&gt;
Tested-by: Imanti Mendez &lt;imanti.mendez@oracle.com&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>RDS: make message size limit compliant with spec</title>
<updated>2017-01-02T22:02:57Z</updated>
<author>
<name>Avinash Repaka</name>
</author>
<published>2016-02-29T23:30:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f9fb69adb6c7acca60977a4db5a5f95b8e66c041'/>
<id>urn:sha1:f9fb69adb6c7acca60977a4db5a5f95b8e66c041</id>
<content type='text'>
RDS support max message size as 1M but the code doesn't check this
in all cases. Patch fixes it for RDMA &amp; non-RDMA and RDS MR size
and its enforced irrespective of underlying transport.

Signed-off-by: Avinash Repaka &lt;avinash.repaka@oracle.com&gt;
Signed-off-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.com&gt;
</content>
</entry>
</feed>
