All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] rds: mark bound socket with SOCK_RCU_FREE
@ 2018-09-10 22:24 Cong Wang
  2018-09-10 22:34 ` Sowmini Varadhan
  2018-09-10 22:43 ` Santosh Shilimkar
  0 siblings, 2 replies; 13+ messages in thread
From: Cong Wang @ 2018-09-10 22:24 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Sowmini Varadhan, Santosh Shilimkar, rds-devel

When a rds sock is bound, it is inserted into the bind_hash_table
which is protected by RCU. But when releasing rd sock, after it
is removed from this hash table, it is freed immediately without
respecting RCU grace period. This could cause some use-after-free
as reported by syzbot.

Mark the rds sock as SOCK_RCU_FREE before inserting it into the
bind_hash_table, so that it would be always freed after a RCU grace
period.

Reported-and-tested-by: syzbot+8967084bcac563795dc6@syzkaller.appspotmail.com
Cc: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Cc: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Cc: rds-devel@oss.oracle.com
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/rds/bind.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/rds/bind.c b/net/rds/bind.c
index 3ab55784b637..2281b34415b9 100644
--- a/net/rds/bind.c
+++ b/net/rds/bind.c
@@ -235,6 +235,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		goto out;
 	}
 
+	sock_set_flag(sk, SOCK_RCU_FREE);
 	ret = rds_add_bound(rs, binding_addr, &port, scope_id);
 	if (ret)
 		goto out;
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-09-11  5:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 22:24 [Patch net] rds: mark bound socket with SOCK_RCU_FREE Cong Wang
2018-09-10 22:34 ` Sowmini Varadhan
2018-09-10 22:43 ` Santosh Shilimkar
2018-09-10 23:30   ` Sowmini Varadhan
2018-09-10 23:51     ` Cong Wang
2018-09-11  0:04       ` Sowmini Varadhan
2018-09-11  0:16         ` Cong Wang
2018-09-11  0:24           ` Sowmini Varadhan
2018-09-11  0:39             ` Cong Wang
2018-09-11  0:26           ` Santosh Shilimkar
2018-09-11  0:45             ` Cong Wang
2018-09-11  0:56               ` Santosh Shilimkar
2018-09-11  0:59                 ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.