Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
On Mon, Sep 10, 2018 at 5:56 PM Santosh Shilimkar wrote: > > On 9/10/2018 5:45 PM, Cong Wang wrote: > > On Mon, Sep 10, 2018 at 5:26 PM Santosh Shilimkar > > wrote: > >> Would you mind posting an updated patch please with call_rcu and > >> above extended RCU grace period with rcu_read_lock. Thank

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Santosh Shilimkar
On 9/10/2018 5:45 PM, Cong Wang wrote: On Mon, Sep 10, 2018 at 5:26 PM Santosh Shilimkar wrote: Would you mind posting an updated patch please with call_rcu and above extended RCU grace period with rcu_read_lock. Thanks !! If you prefer to fix _two_ problems in one patch, sure. For the recor

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
On Mon, Sep 10, 2018 at 5:26 PM Santosh Shilimkar wrote: > Would you mind posting an updated patch please with call_rcu and > above extended RCU grace period with rcu_read_lock. Thanks !! If you prefer to fix _two_ problems in one patch, sure. For the record, the bug this patch fixes is NOT same

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
On Mon, Sep 10, 2018 at 5:24 PM Sowmini Varadhan wrote: > > On (09/10/18 17:16), Cong Wang wrote: > > > > > > On (09/10/18 16:51), Cong Wang wrote: > > > > > > > > __rds_create_bind_key(key, addr, port, scope_id); > > > > - rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms)

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Santosh Shilimkar
On 9/10/2018 5:16 PM, Cong Wang wrote: On Mon, Sep 10, 2018 at 5:04 PM Sowmini Varadhan wrote: On (09/10/18 16:51), Cong Wang wrote: __rds_create_bind_key(key, addr, port, scope_id); - rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); + rcu_read_lock(); +

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Sowmini Varadhan
On (09/10/18 17:16), Cong Wang wrote: > > > > On (09/10/18 16:51), Cong Wang wrote: > > > > > > __rds_create_bind_key(key, addr, port, scope_id); > > > - rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); > > > + rcu_read_lock(); > > > + rs = rhashtable_lookup(&

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
On Mon, Sep 10, 2018 at 5:04 PM Sowmini Varadhan wrote: > > On (09/10/18 16:51), Cong Wang wrote: > > > > __rds_create_bind_key(key, addr, port, scope_id); > > - rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); > > + rcu_read_lock(); > > + rs = rhashtable_loo

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Sowmini Varadhan
On (09/10/18 16:51), Cong Wang wrote: > > __rds_create_bind_key(key, addr, port, scope_id); > - rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); > + rcu_read_lock(); > + rs = rhashtable_lookup(&bind_hash_table, key, ht_parms); > if (rs && !sock_flag(r

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
On Mon, Sep 10, 2018 at 4:30 PM Sowmini Varadhan wrote: > > On (09/10/18 15:43), Santosh Shilimkar wrote: > > On 9/10/2018 3:24 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 rd sock, after it > > >is r

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Sowmini Varadhan
On (09/10/18 15:43), Santosh Shilimkar wrote: > On 9/10/2018 3:24 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 rd sock, after it > >is removed from this hash table, it is freed immediately without > >respe

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Santosh Shilimkar
On 9/10/2018 3:24 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 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-fr

Re: [Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Sowmini Varadhan
On (09/10/18 15:24), 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 rd sock, after it > is removed from this hash table, it is freed immediately without > respecting RCU grace period. This could cause some use-

[Patch net] rds: mark bound socket with SOCK_RCU_FREE

2018-09-10 Thread Cong Wang
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 s