From mboxrd@z Thu Jan 1 00:00:00 1970 From: Santosh Shilimkar Subject: Re: [Patch net v2] rds: fix two RCU related problems Date: Mon, 10 Sep 2018 18:33:03 -0700 Message-ID: References: <20180911012726.5353-1-xiyou.wangcong@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Sowmini Varadhan , rds-devel@oss.oracle.com To: Cong Wang , netdev@vger.kernel.org Return-path: Received: from userp2130.oracle.com ([156.151.31.86]:37414 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbeIKG3z (ORCPT ); Tue, 11 Sep 2018 02:29:55 -0400 In-Reply-To: <20180911012726.5353-1-xiyou.wangcong@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 9/10/2018 6:27 PM, Cong Wang wrote: > 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 > Cc: Santosh Shilimkar > Cc: rds-devel@oss.oracle.com > Signed-off-by: Cong Wang > --- Thank you !! Acked-by: Santosh Shilimkar