]> git.baikalelectronics.ru Git - kernel.git/commit
rds: fix two RCU related problems
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 11 Sep 2018 01:27:26 +0000 (18:27 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Sep 2018 07:09:19 +0000 (00:09 -0700)
commitbb60a8c3d6e3b507bee31bf6106e4dc511af589c
treedd8d719e691092423031333cf0b834623f432086
parentc7b6e33206822564ecf95b6e9ef6847b7e775ac5
rds: fix two RCU related problems

When a rds sock is bound, it is inserted into the bind_hash_table
which is protected by RCU. But when releasing rds 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 with SOCK_RCU_FREE before inserting it into the
bind_hash_table, so that it would be always freed after a RCU grace
period.

The other problem is in rds_find_bound(), the rds sock could be
freed in between rhashtable_lookup_fast() and rds_sock_addref(),
so we need to extend RCU read lock protection in rds_find_bound()
to close this race condition.

Reported-and-tested-by: syzbot+8967084bcac563795dc6@syzkaller.appspotmail.com
Reported-by: syzbot+93a5839deb355537440f@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>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oarcle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/bind.c