[Devel] [PATCH RHEL8 COMMIT] ve/net: don't use RCU read lock in ve_dev_can_rename()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 8 18:44:41 MSK 2019


The commit is pushed to "branch-rh8-4.18.0-32.vz8.1.x" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-32.el8
------>
commit 5b71c68a2f2b4927215f4ade4916a8d75d1eb014
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Mon Apr 8 15:27:05 2019 +0300

    ve/net: don't use RCU read lock in ve_dev_can_rename()
    
    rcu_read_lock()/unlock won't help here anyway:
    "can" value can change right after rcu lock is dropped.
    
    Fixes: 13bed5e31b7c ("ve/net: allow to rename devices in non-ve
    namespaces")
    https://jira.sw.ru/browse/PSBM-93640
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 net/core/dev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 29b0ebaeefe9..c7f317de17b8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1170,9 +1170,12 @@ static bool ve_dev_can_rename(struct net_device *dev)
 	struct net *net;
 	bool can;
 
-	net = ve_net_lock(dev_net(dev)->owner_ve);
+	/*
+	 * rcu_read_lock()/unlock won't help here anyway:
+	 * "can" value can change right after rcu lock is dropped.
+	 */
+	net = rcu_dereference(dev_net(dev)->owner_ve->ve_ns)->net_ns;
 	can = !net || net == dev_net(dev);
-	ve_net_unlock(dev_net(dev)->owner_ve);
 	return can;
 }
 



More information about the Devel mailing list