Skip to contentSkip to conversation

cgroup-v1: add disabled controller check in cgroup1_parse_param()

PATCH In review Chen Zhou 2 participants 3 messages Oct 12, 2020 – Oct 27, 2020 2 messages not in the archive cgroup

lore
Share & tools
lore

Chen Zhou

author
#0 lore raw

PATCH 1/1 cgroup-v1: add disabled controller check in cgroup1_parse_param()

When mounting a cgroup hierarchy with disabled controller in cgroup v1, all available controllers will be attached.

Add disabled controller check in cgroup1_parse_param() and return directly if the specified controller is disabled.

---
 kernel/cgroup/cgroup-v1.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/cgroup/cgroup-v1.c +2 -0
index 191c329e482a..7427d47ad26f 100644
@@ -915,6 +915,8 @@ 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;
 		}
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): 20201012102757.83192-1-chenzhou10-hv44wF8Li93QT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 7 lines · Chen Zhou

When mounting a cgroup hierarchy with disabled controller in cgroup v1, all available controllers will be attached.

Add disabled controller check in cgroup1_parse_param() and return directly if the specified controller is disabled.

check_cgroupfs_options() is already checking the condition. How does also checking in parse_param() help?

Thanks.

Signature · 1 line
tejun

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw
Quoted 10 lines · Tejun Heo
Quoted 7 lines · Chen Zhou

When mounting a cgroup hierarchy with disabled controller in cgroup v1, all available controllers will be attached.

Add disabled controller check in cgroup1_parse_param() and return directly if the specified controller is disabled.

check_cgroupfs_options() is already checking the condition. How does also checking in parse_param() help?

Hi Tejun,

Function check_cgroupfs_options() don't check if the mounted controller is disabled. It just gets the enabled controllers firstly, and then do & opteration with the mounted controller. If the result is NULL, just select all the enabled controllers.

This patch check if the specified controller of mount is disabled, and return "Disabled controller xx" error if true.

Thanks,
Chen Zhou

Quoted 3 lines

Thanks.