[PATCH 01/23] resctrl: Fix ownership of resource_schemata control subdirectories

From: Fenghua Yu

Date: Thu Jul 16 2026 - 17:03:54 EST


resctrl_mkdir_schemata_dir() creates a control subdirectory (kn_ctrl)
for each control under resource_schemata, but applied ownership to the
parent resource_schemata directory (kn_subdir) instead of the newly
created subdirectory.

rdtgroup_kn_set_ugid() is a no-op when both uid and gid are root, so on
the common root mount this is harmless. On a non-root resctrl mount,
however, each control subdirectory keeps root:root ownership instead of
inheriting the mounting user's credentials.

Apply the ownership to kn_ctrl so each control subdirectory gets the
correct uid/gid.

On error, resctrl_mkdir_schemata_dir() intentionally does not unwind
partially created nodes (see the comment above the function). The sole
caller, rdtgroup_create_info_dir(), removes the whole info subtree via
kernfs_remove(kn_info), which recursively frees resource_schemata and
any control subdirectories already created.

Signed-off-by: Fenghua Yu <fenghuay@xxxxxxxxxx>
---
fs/resctrl/rdtgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5ccd09b16e0f..2abb7fda6091 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2728,7 +2728,7 @@ static int resctrl_mkdir_schemata_dir(struct kernfs_node *kn,
if (IS_ERR(kn_ctrl))
return PTR_ERR(kn_ctrl);

- ret = rdtgroup_kn_set_ugid(kn_subdir);
+ ret = rdtgroup_kn_set_ugid(kn_ctrl);
if (ret)
return ret;

--
2.43.0