Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp229090pxb; Fri, 15 Jan 2021 01:33:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwr/pAAwCXv72JyGGq9AdhAW8y0/JqU3A7htqahoDqbPB4BmuQamwDgGI0Cz31PwM6H0rWP X-Received: by 2002:a17:906:31cb:: with SMTP id f11mr8436910ejf.468.1610703237790; Fri, 15 Jan 2021 01:33:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610703237; cv=none; d=google.com; s=arc-20160816; b=G7+hvpDm700/HsNs3lxlFy3dp7LOUhDNy27jNhHmrhUz0pe1AligPp79J60eyr87ej mnguert/cTmqJVQ7Awi12s+Hdse7wu+ey/zTLqEvIUJitRB36Q6ITLDrpN3Ickt2vg8+ g4A6qOyMyl9B5iXiB8m8whgyuCth4llipdpX1xJ+Ry5pVbkOWiLH014CkDavGvKSkyZJ Yxe3o+fKv130vGD/jOu4+wSDOlmRPA8awXB3jxAUbeE50lLnUJLz/lA3uMZ96KIOslPA ZTKgvgo38kNudPTNuD0BxnvW7NiPzhtez+1ajr38qgg4sYGZVPJXrJ5vASJmMvt/Qfjr TPlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=M1VMzeiio2wE+GvC6ENj6ZN5lzieZa0UuX8nSrKqc8k=; b=ZL2XaOTt8eCwxoaDxsFgE+hXgmRVDxF5KT/4Xq27hXvsXP2idOfNWxus6Qf+4wPBX9 TG8Ink9xSvBwY2FsKFacdtgvIGCwNATwllWW/L4RY9inE8kH6bQMWUp8hWFPOwpwjhIy DurV5yTZSB+PA7HHKgq8y243EBb82OE0kkXNlnKM4IWEu30F46/lFpPXvZ5R33v5avI5 7m9iI9d/6v1KFDZK+v9+v8UJsxNH8i+q1BZKy6+r8CNhx+fqaFeYUSes8K+Cg1EDlpiC 4eNLRK1YXA16vqUNeei1SEiUurIvzbejcvt1z2+OEDmdJG+E2lWKoj8CXmWzAN2xjYlE 4tjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si3906635edy.201.2021.01.15.01.33.33; Fri, 15 Jan 2021 01:33:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729581AbhAOJcr (ORCPT + 99 others); Fri, 15 Jan 2021 04:32:47 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10659 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbhAOJcp (ORCPT ); Fri, 15 Jan 2021 04:32:45 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DHGBm3z4gz15pqt; Fri, 15 Jan 2021 17:30:56 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Fri, 15 Jan 2021 17:31:51 +0800 From: Chen Zhou To: , , CC: , , , , , Subject: [PATCH v3] cgroup-v1: add disabled controller check in cgroup1_parse_param() Date: Fri, 15 Jan 2021 17:37:17 +0800 Message-ID: <20210115093717.79474-1-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When mounting a cgroup hierarchy with disabled controller in cgroup v1, all available controllers will be attached. For example, boot with cgroup_no_v1=cpu or cgroup_disable=cpu, and then mount with "mount -t cgroup -ocpu cpu /sys/fs/cgroup/cpu", then all enabled controllers will be attached except cpu. Fix this by adding disabled controller check in cgroup1_parse_param(). If the specified controller is disabled, just return error with information "Disabled controller xx" rather than attaching all the other enabled controllers. Fixes: f5dfb5315d34 ("cgroup: take options parsing into ->parse_monolithic()") Signed-off-by: Chen Zhou Reviewed-by: Zefan Li --- Changes in v3: - Update the description of commit message. - Add Reviewed-by from Zefan. Changes in v2: - Fix line over 80 characters warning. --- kernel/cgroup/cgroup-v1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 32596fdbcd5b..a5751784ad74 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -917,6 +917,9 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) for_each_subsys(ss, i) { if (strcmp(param->key, ss->legacy_name)) continue; + if (!cgroup_ssid_enabled(i) || cgroup1_ssid_disabled(i)) + return invalfc(fc, "Disabled controller '%s'", + param->key); ctx->subsys_mask |= (1 << i); return 0; } -- 2.20.1