[Devel] [PATCH 1/2] vznetstat: Add protection to venet_acct_set_classes()
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Dec 19 15:24:33 MSK 2017
It seems there was no synchronization since the time
when ioctls in kernel were serialized via single mutex.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
kernel/ve/vznetstat/vznetstat.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/ve/vznetstat/vznetstat.c b/kernel/ve/vznetstat/vznetstat.c
index 3a53ce27bde2..a65e05378ff4 100644
--- a/kernel/ve/vznetstat/vznetstat.c
+++ b/kernel/ve/vznetstat/vznetstat.c
@@ -52,6 +52,7 @@ static struct class_info_set *info_v4 = NULL;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static struct class_info_set *info_v6 = NULL;
#endif
+static DEFINE_MUTEX(info_mutex);
/* v6: flag IPv6 classes or IPv4 */
static int venet_acct_set_classes(const void __user *user_info, int length, int v6)
@@ -88,15 +89,17 @@ static int venet_acct_set_classes(const void __user *user_info, int length, int
goto out_free;
}
- rcu_read_lock();
+ mutex_lock(&info_mutex);
if (v6) {
- old = rcu_dereference(info_v6);
+ old = rcu_dereference_protected(info_v6,
+ lockdep_is_held(&info_mutex));
rcu_assign_pointer(info_v6, info);
} else {
- old = rcu_dereference(info_v4);
+ old = rcu_dereference_protected(info_v4,
+ lockdep_is_held(&info_mutex));
rcu_assign_pointer(info_v4, info);
}
- rcu_read_unlock();
+ mutex_unlock(&info_mutex);
synchronize_net();
/* IMPORTANT. I think reset of statistics collected should not be
More information about the Devel
mailing list