From 8672d55231be8d082ba2e9c9d866f5a7ee0c79c6 Mon Sep 17 00:00:00 2001 From: gaochao Date: Mon, 21 Feb 2022 19:59:01 +0800 Subject: [PATCH] cpuset: fix cpumask_subset when setting inval cpus ohos inclusion category: bugfix issue: #I4UE7J CVE: NA ------------------------------------------- To show the problem: # cat /proc/cpuinfo | grep -i processor | wc -l 8 # cat cpus # echo 8 > cpus # cat cpus # echo 0-8 > cpus # cat cpus 0-7 # With patch: # cat /proc/cpuinfo | grep -i processor | wc -l 8 # cat cpus # echo 8 > cpus sh: write error: Invalid argument # cat cpus # # echo 0-8 > cpus sh: write error: Invalid argument # # cat cpus # fix cpumask_subset in update_cpumask when setting inval cpus Signed-off-by: gaochao --- kernel/cgroup/cpuset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index c33d70215079..3173fe47380a 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1539,16 +1539,16 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, return retval; } - if (!cpumask_subset(trialcs->cpus_requested, top_cpuset.cpus_requested)) + if (!cpumask_subset(trialcs->cpus_requested, cpu_present_mask)) return -EINVAL; + cpumask_and(trialcs->cpus_allowed, trialcs->cpus_requested, + cpu_active_mask); + /* Nothing to do if the cpus didn't change */ if (cpumask_equal(cs->cpus_requested, trialcs->cpus_requested)) return 0; - cpumask_and(trialcs->cpus_allowed, trialcs->cpus_requested, - cpu_active_mask); - retval = validate_change(cs, trialcs); if (retval < 0) return retval; -- Gitee