[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 19:06:50 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 cc7a59b151eea9ca8c3da2f57e25c37d81560c51
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..43ff941aeaa7 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_check(dev_net(dev)->owner_ve->ve_ns, 1)->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