From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id F0B7F7D048 for ; Wed, 30 May 2018 13:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752780AbeE3Nqt (ORCPT ); Wed, 30 May 2018 09:46:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750757AbeE3Nqs (ORCPT ); Wed, 30 May 2018 09:46:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A60AC6F596; Wed, 30 May 2018 13:46:47 +0000 (UTC) Received: from llong.com (dhcp-17-81.bos.redhat.com [10.18.17.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FBB820357CA; Wed, 30 May 2018 13:46:46 +0000 (UTC) From: Waiman Long To: Tejun Heo , Li Zefan , Johannes Weiner , Peter Zijlstra , Ingo Molnar Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, Mike Galbraith , torvalds@linux-foundation.org, Roman Gushchin , Juri Lelli , Patrick Bellasi , Waiman Long Subject: [PATCH] cpuset: Enforce that a child's cpus must be a subset of the parent Date: Wed, 30 May 2018 09:46:31 -0400 Message-Id: <1527687991-1431-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 30 May 2018 13:46:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 30 May 2018 13:46:47 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org It was found that the cpuset.cpus could contain CPUs that are not listed in their parent's cpu list as shown by the command sequence below: # echo "+cpuset" >cgroup.subtree_control # mkdir g1 # echo 0-5 >g1/cpuset.cpus # mkdir g1/g11 # echo "+cpuset" > g1/cgroup.subtree_control # echo 6-11 >g1/g11/cpuset.cpus # grep -R . g1 | grep "\.cpus" g1/cpuset.cpus:0-5 g1/cpuset.cpus.effective:0-5 g1/g11/cpuset.cpus:6-11 g1/g11/cpuset.cpus.effective:0-5 As the intersection of g11's cpus and that of g1 is empty, the effective cpus of g11 is just that of g1. The check in update_cpumask() is now corrected to make sure that cpus in a child cpus must be a subset of its parent's cpus. The error "write error: Invalid argument" will now be reported in the above case. Reported-by: Juri Lelli Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 71fb2d0..ceec438 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1185,12 +1185,17 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, if (!*buf) { cpumask_clear(trialcs->cpus_allowed); } else { + struct cpuset *parent = parent_cs(cs); + retval = cpulist_parse(buf, trialcs->cpus_allowed); if (retval < 0) return retval; + /* + * The cpu list must be a subset of the parent. + */ if (!cpumask_subset(trialcs->cpus_allowed, - top_cpuset.cpus_allowed)) + parent->cpus_allowed)) return -EINVAL; } -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html