net: openvswitch: silence suspicious RCU usage warning
Subsystems (3)
Eelco Chaudron
maintainerPATCH 1/1 net: openvswitch: silence suspicious RCU usage warning
Silence suspicious RCU usage warning in ovs_flow_tbl_masks_cache_resize() by replacing rcu_dereference() with rcu_dereference_ovsl().
In addition, when creating a new datapath, make sure it's configured under the ovs_lock.
--- net/openvswitch/datapath.c | 8 ++++---- net/openvswitch/flow_table.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
net/openvswitch/datapath.c +4 -4
@@ -1695,6 +1695,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_ports; +/* So far only local changes have been made, now need the lock. */ +ovs_lock (); +/* Set up our datapath device. */ parms.name =nla_data (a[OVS_DP_ATTR_NAME ]); parms.type =OVS_VPORT_TYPE_INTERNAL ;
@@ -1707,9 +1710,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_meters; -/* So far only local changes have been made, now need the lock. */ -ovs_lock (); - vport =new_vport (&parms);if (IS_ERR (vport)) { err =PTR_ERR (vport);
@@ -1725,7 +1725,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)ovs_dp_reset_user_features (skb, info); } -ovs_unlock (); goto err_destroy_meters; }
@@ -1742,6 +1741,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)return 0 ; err_destroy_meters: +ovs_unlock ();ovs_meters_exit (dp); err_destroy_ports:kfree (dp->ports);
net/openvswitch/flow_table.c +1 -1
@@ -390,7 +390,7 @@ static struct mask_cache *tbl_mask_cache_alloc(u32 size) }int ovs_flow_tbl_masks_cache_resize (struct flow_table *table,u32 size) { -struct mask_cache *mc =rcu_dereference (table->mask_cache); +struct mask_cache *mc =rcu_dereference_ovsl (table->mask_cache);struct mask_cache *new;if (size == mc->cache_size)
Jakub Kicinski
maintainerQuoted 19 lines · On Thu, 29 Oct 2020 15:53:21 +0100 Eelco Chaudron wrote:
Silence suspicious RCU usage warning in
ovs_flow_tbl_masks_cache_resize()by replacingrcu_dereference()withrcu_dereference_ovsl().In addition, when creating a new datapath, make sure it's configured under the
ovs_lock.Fixes 9bf24f594c6a ("net: openvswitch: make masks cache size configurable")Reported-by [email protected]Signed-off-by Eelco Chaudron <[email protected]>--- net/openvswitch/datapath.c | 8 ++++---- net/openvswitch/flow_table.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)net/openvswitch/datapath.c +0
-0
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) · line 1699
Quoted 5 lines
net/openvswitch/datapath.c +2
-0@@ -1695,6 +1695,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_ports; +/* So far only local changes have been made, now need the lock. */ +ovs_lock ();
Should we move the lock below assignments to param?
Looks a little strange to protect stack variables with a global lock.
Quoted 22 lines
net/openvswitch/datapath.c +0
-4/* Set up our datapath device. */ parms.name =nla_data (a[OVS_DP_ATTR_NAME ]); parms.type =OVS_VPORT_TYPE_INTERNAL ;@@ -1707,9 +1710,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_meters; -/* So far only local changes have been made, now need the lock. */ -ovs_lock (); - vport =new_vport (&parms);if (IS_ERR (vport)) { err =PTR_ERR (vport);@@ -1725,7 +1725,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)ovs_dp_reset_user_features (skb, info); } -ovs_unlock (); goto err_destroy_meters; }
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) · line 1743
Quoted 3 lines
net/openvswitch/datapath.c +0
-0@@ -1742,6 +1741,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)return 0 ; err_destroy_meters:
Let's update the name of the label.
Quoted 18 lines
net/openvswitch/datapath.c +1
-0+ovs_unlock ();ovs_meters_exit (dp); err_destroy_ports:kfree (dp->ports);net/openvswitch/flow_table.c +1
-1@@ -390,7 +390,7 @@ static struct mask_cache *tbl_mask_cache_alloc(u32 size) }int ovs_flow_tbl_masks_cache_resize (struct flow_table *table,u32 size) { -struct mask_cache *mc =rcu_dereference (table->mask_cache); +struct mask_cache *mc =rcu_dereference_ovsl (table->mask_cache);struct mask_cache *new;if (size == mc->cache_size)
Eelco Chaudron
maintainerQuoted 24 lines · Jakub Kicinski
Quoted 23 lines · On Thu, 29 Oct 2020 15:53:21 +0100 Eelco Chaudron wrote:
Silence suspicious RCU usage warning in
ovs_flow_tbl_masks_cache_resize()by replacingrcu_dereference()withrcu_dereference_ovsl().In addition, when creating a new datapath, make sure it's configured under the
ovs_lock.Fixes 9bf24f594c6a ("net: openvswitch: make masks cache size configurable")Reported-by [email protected]Signed-off-by Eelco Chaudron <[email protected]>--- net/openvswitch/datapath.c | 8 ++++---- net/openvswitch/flow_table.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)net/openvswitch/datapath.c +0
-0@@ -1695,6 +1695,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_ports;
Quoted 6 lines
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) · line 1699
Quoted 2 lines
net/openvswitch/datapath.c +2
-0+/* So far only local changes have been made, now need the lock. */ +ovs_lock ();Should we move the lock below assignments to param?
Looks a little strange to protect stack variables with a global lock.
You are right, I should have moved it down after the assignment. I will send out a v2.
Quoted 23 lines
Quoted 23 lines
net/openvswitch/datapath.c +0
-3/* Set up our datapath device. */ parms.name =nla_data (a[OVS_DP_ATTR_NAME ]); parms.type =OVS_VPORT_TYPE_INTERNAL ;@@ -1707,9 +1710,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_meters; -/* So far only local changes have been made, now need the lock. */ -ovs_lock (); - vport =new_vport (&parms);if (IS_ERR (vport)) {net/openvswitch/datapath.c +0
-1err =PTR_ERR (vport);@@ -1725,7 +1725,6 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)ovs_dp_reset_user_features (skb ,info ); } -ovs_unlock (); goto err_destroy_meters; }
Quoted 7 lines
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, · line 1744
Quoted 5 lines
net/openvswitch/datapath.c +0
-0@@ -1742,6 +1741,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)return 0 ; err_destroy_meters:Let's update the name of the label.
Guess now it is, unlock and destroy meters, so what label are you looking for?
err_unlock_and_destroy_meters: which looks a bit long, or just err_unlock:
Quoted 20 lines
Quoted 20 lines
net/openvswitch/datapath.c +1
-0+ovs_unlock ();ovs_meters_exit (dp); err_destroy_ports:net/openvswitch/datapath.c +0
-0kfree (dp->ports);net/openvswitch/flow_table.c +1
-1@@ -390,7 +390,7 @@ static struct mask_cache *tbl_mask_cache_alloc(u32 size) }int ovs_flow_tbl_masks_cache_resize (struct flow_table *table,u32 size) { -struct mask_cache *mc =rcu_dereference (table->mask_cache); +struct mask_cache *mc =rcu_dereference_ovsl (table->mask_cache);struct mask_cache *new;if (size ==
mc->cache_size)
Jakub Kicinski
maintainerQuoted 16 lines · On Mon, 02 Nov 2020 09:52:19 +0100 Eelco Chaudron wrote:
Quoted 11 lines · Jakub Kicinski
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, · line 1700
Quoted 7 lines
net/openvswitch/datapath.c +2
-0@@ -1695,6 +1695,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_ports; +/* So far only local changes have been made, now need the lock. */ +ovs_lock ();Should we move the lock below assignments to param?
Looks a little strange to protect stack variables with a global lock.
You are right, I should have moved it down after the assignment. I will send out a v2.
Quoted 7 lines
Quoted 1 line
Let's update the name of the label.
Guess now it is, unlock and destroy meters, so what label are you looking for?
err_unlock_and_destroy_meters: which looks a bit long, or justerr_unlock:
I feel like I saw some names like err_unlock_and_destroy_meters in OvS code, but can't find them in this file right now.
I'd personally go for kist err_unlock, or maybe err_unlock_ovs as is used in other functions in this file.
But as long as it starts with err_unlock it's fine by me :)
Eelco Chaudron
maintainerQuoted 25 lines · Jakub Kicinski
Quoted 16 lines · On Mon, 02 Nov 2020 09:52:19 +0100 Eelco Chaudron wrote:
Quoted 11 lines · Jakub Kicinski
net/openvswitch/datapath.c static int ovs_dp_cmd_new(struct sk_buff *skb, · line 1700
Quoted 7 lines
net/openvswitch/datapath.c +2
-0@@ -1695,6 +1695,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)if (err) goto err_destroy_ports; +/* So far only local changes have been made, now need the lock. */ +ovs_lock ();Should we move the lock below assignments to param?
Looks a little strange to protect stack variables with a global lock.
You are right, I should have moved it down after the assignment. I will send out a v2.
Quoted 7 lines
Quoted 1 line
Let's update the name of the label.
Guess now it is, unlock and destroy meters, so what label are you looking for?
err_unlock_and_destroy_meters: which looks a bit long, or justerr_unlock:
Quoted 7 lines
I feel like I saw some names like
err_unlock_and_destroy_metersin OvS code, but can't find them in this file right now.I'd personally go for kist
err_unlock, or maybeerr_unlock_ovsas is used in other functions in this file.But as long as it starts with
err_unlockit's fine by me :)
Ack, sent out a v2.