Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5069933pxb; Mon, 15 Feb 2021 08:43:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMCR2Ck/hcDoU9s0TuMrFDVfgmBm4+hJtzI6qna4KgB1wR5obycFPRWqW0G5cUZfthOyf/ X-Received: by 2002:a17:906:d10d:: with SMTP id b13mr16576882ejz.438.1613407390895; Mon, 15 Feb 2021 08:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407390; cv=none; d=google.com; s=arc-20160816; b=vB7d4pn+PjaPSmm/T5/CpbDpiH7lVH6Z3bwzkQJnc89UHDlMBtMy5ixA19OpFMnBlx tXjVok260gt9QtHdDgVUdcoFHm5B2DtBamaTcka7MBsfJsRbeD6teoCKPSrL/ozQm1qj hFd8YHDg0X2OqJWFWCx8jbI+YTLHkOermePwEiarKf+tDIW4/tVHw10koxCQepX5NT4g avXkP4I0xOEYDTQFv+8Bqtwox+j81kyp2sPU74yUQxGPtK1h/mKE07Pkd7QQVvaK3eXo 4ilfj6f8mHi9SW1iBd7QgC90V8f7gJ1JETaaHgCOnXUHqm1PPRUP9gm6om9hyBlSt0SM ZuVg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9orqfUQqO8vKYgavHam/0MY3P2aJmFhQ34kbCu4IfPc=; b=UKFcbSlDriD4yBvbOBc2PXD82ld0qD3tFfvaq7mJ5FdFhkwr+u2NUhjCbSbeZH5SKF QB6lyFZHQbuggAPSsRlvAR6hWDgYorIzhjt8Bhf9Rf4XQ51ZvX/lgX8C+oruD+BKD76o pA09RSC3vfC4EeQAVeJT4LnkwOLLEibibAvaELoUH/dVwEvb9WAHI0zOc+NUp/m5degX f2TvYQyibWmKqmvWsVAYb1sdJIqHtBnryBPs/OcTFoAdO1cGClWTN2ni4/ljAd6my00x sR+UXI5dBnvf4AEg8B8BLr0/JI52qWTeufGBqkbC8ZF15oNSO/1tn+kn1R9WEaLsUI2M dSPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=srq2uu2y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si12888624edm.396.2021.02.15.08.42.46; Mon, 15 Feb 2021 08:43:10 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=srq2uu2y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231261AbhBOQj5 (ORCPT + 99 others); Mon, 15 Feb 2021 11:39:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:49600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbhBOPgz (ORCPT ); Mon, 15 Feb 2021 10:36:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B6DB64ED7; Mon, 15 Feb 2021 15:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403154; bh=LnPdiWxmYswvudyCPnAmeCke0qm0uWWt2RBavlq4lGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=srq2uu2yQzRpu4EVOyzQMWVZtDgAVLfazGvsKUA7xOYLiSTWDhndJR0CgLi0dSe4C dIIWTbkigzmHft6jC5HLCtGC68GVSjLXe6O1+Do4esXYk7LlXAZZCBG0HHRArRMW/d XsmIESq3/wIki/Ks7r/1oLoNmzIKTcj89jpw0eVI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Zhou , Zefan Li , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Tejun Heo , Sasha Levin Subject: [PATCH 5.10 049/104] cgroup-v1: add disabled controller check in cgroup1_parse_param() Date: Mon, 15 Feb 2021 16:27:02 +0100 Message-Id: <20210215152721.061913782@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen Zhou [ Upstream commit 61e960b07b637f0295308ad91268501d744c21b5 ] 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 Reviewed-by: Michal Koutný Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- 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 32596fdbcd5b8..a5751784ad740 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.27.0