[drivers/net/vxlan]Why rcu_read_lock is not obtained before rculist travelling

3 messages, 2 authors, 2017-03-01 · open the first message on its own page

[drivers/net/vxlan]Why rcu_read_lock is not obtained before rculist travelling

From: 颜小波 <hidden>
Date: 2017-02-28 14:19:03

Hi Stephen,


I am studying vxlan device driver in 4.10 kernel. I see that vxlan_fdb in fdb_head list is rcu protected. call_rcu is invoked to free vxlan fdb, which will defer the vxlan_fdb_free until all rcu reads exist the race condition. 

But I don’t find any rcu_read_lock invoked before travelling fdb_head list.  In vxlan_xmit and vxlan_snoop function, vxlan_find_mac function is called to search the vxlan_fdb of the dst_mac or src_mac. Then information in vxlan_fdb  is used for further process.  But as no rcu_read_lock is obtained before the list travelling, I am wondering if it is possible that vxlan_fdb is freed when it is being used. 

static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f)
{
       netdev_dbg(vxlan->dev,
                  "delete %pM\n", f->eth_addr);

       --vxlan->addrcnt;
       vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_DELNEIGH);

       hlist_del_rcu(&f->hlist);
       call_rcu(&f->rcu, vxlan_fdb_free);
}


Thanks

Xiaobo

Re: [drivers/net/vxlan]Why rcu_read_lock is not obtained before rculist travelling

From: Cong Wang <hidden>
Date: 2017-02-28 21:38:03

On Tue, Feb 28, 2017 at 6:03 AM, 颜小波 [off-list ref] wrote:
But I don’t find any rcu_read_lock invoked before travelling fdb_head list.  In vxlan_xmit and vxlan_snoop function, vxlan_find_mac function is called to search the vxlan_fdb of the dst_mac or src_mac. Then information in vxlan_fdb  is used for further process.  But as no rcu_read_lock is obtained before the list travelling, I am wondering if it is possible that vxlan_fdb is freed when it is being used.
In both RX and TX paths, rcu read lock is acquired by upper layer.
Check __dev_queue_xmit() and process_backlog().

Re:Re: [drivers/net/vxlan]Why rcu_read_lock is not obtained before rculist travelling

From: Xiaobo Yan <hidden>
Date: 2017-03-01 18:05:49

Hi Cong,

Thanks very much for your reply.  It's indeeded acquired by upper layer.

Thanks

At 2017-03-01 05:29:17, "Cong Wang" [off-list ref] wrote:
On Tue, Feb 28, 2017 at 6:03 AM, Xiaobo Yan [off-list ref] wrote:
quoted
But I don’t find any rcu_read_lock invoked before travelling fdb_head list.  In vxlan_xmit and vxlan_snoop function, vxlan_find_mac function is called to search the vxlan_fdb of the dst_mac or src_mac. Then information in vxlan_fdb  is used for further process.  But as no rcu_read_lock is obtained before the list travelling, I am wondering if it is possible that vxlan_fdb is freed when it is being used.
In both RX and TX paths, rcu read lock is acquired by upper layer.
Check __dev_queue_xmit() and process_backlog().
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help