[PATCH v7 6/7] cgroup/cpuset: Use cpuset_mutex to protect seq_show operations

From: Juri Lelli
Date: Wed Apr 03 2019 - 04:47:34 EST


cpuset_common_seq_show operations atomicity is currently guarded by
callback_lock. Since these operations are initiated by userspace holding
a raw_spin_lock is not wise.

Convert the function to use cpuset_mutex to fix the problem.

Signed-off-by: Juri Lelli <juri.lelli@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index cb5ff6ca5d2c..91ef48bbc08d 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2444,7 +2444,7 @@ static int cpuset_common_seq_show(struct seq_file *sf, void *v)
cpuset_filetype_t type = seq_cft(sf)->private;
int ret = 0;

- raw_spin_lock_irq(&callback_lock);
+ mutex_lock(&cpuset_mutex);

switch (type) {
case FILE_CPULIST:
@@ -2466,7 +2466,7 @@ static int cpuset_common_seq_show(struct seq_file *sf, void *v)
ret = -EINVAL;
}

- raw_spin_unlock_irq(&callback_lock);
+ mutex_unlock(&cpuset_mutex);
return ret;
}

--
2.17.2