RDS: fix race condition when sending a message on unbound socket 98/118098/2
authorQuentin Casasnovas <quentin.casasnovas@oracle.com>
Tue, 24 Nov 2015 22:13:21 +0000 (17:13 -0500)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 9 Mar 2017 00:26:25 +0000 (16:26 -0800)
commita1cac907a92216089dbe9d51a4d7f2651534ce66
treecada1c6dc0210353b87a07f6b2959a6df839181a
parentabbee71915123ce9fc874c5fe86bc22d01044172
RDS: fix race condition when sending a message on unbound socket

[ Upstream commit 8c7188b23474cca017b3ef354c4a58456f68303a ]

Sasha's found a NULL pointer dereference in the RDS connection code when
sending a message to an apparently unbound socket.  The problem is caused
by the code checking if the socket is bound in rds_sendmsg(), which checks
the rs_bound_addr field without taking a lock on the socket.  This opens a
race where rs_bound_addr is temporarily set but where the transport is not
in rds_bind(), leading to a NULL pointer dereference when trying to
dereference 'trans' in __rds_conn_create().

Vegard wrote a reproducer for this issue, so kindly ask him to share if
you're interested.

I cannot reproduce the NULL pointer dereference using Vegard's reproducer
with this patch, whereas I could without.

Complete earlier incomplete fix to CVE-2015-6937:

  74e98eb08588 ("RDS: verify the underlying transport exists before creating a connection")

Cc: David S. Miller <davem@davemloft.net>
Cc: stable@vger.kernel.org
Change-Id: I7b41743a51bd3213de624d6165c6366c9f808067
Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
[mainline backport of commit 96c7b10cd8000973035b667adf62ea1164f4b9b4]
Change-Id: I7b41743a51bd3213de624d6165c6366c9f808067
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
net/rds/send.c