resctrl is delegated the same way as cgroupfs. A group belongs to whoever created it, and the owner can write to its files, create groups below it, and remove and rename them. A cell with a single id runs with the id of the user who created it, so it owns every group that this user owns. Moving a task to another group through the tasks file is already refused across cells. But other operations affect tasks without checking them: - Removing a group moves its tasks to the parent. - Renaming a monitoring group moves its tasks to another control group. - A write to schemata, cpus or mode changes the conditions that the tasks of the group run under. Creating groups also uses up hardware ids, of which there are only a few for the whole machine. All of this requires a builder that gives the cell access to resctrl. It should not do that, but the boundary of a cell should not depend on nobody making a mistake. No part of resctrl can belong to a cell. So implement may_change() and refuse every change by a task of a cell. Besides cgroupfs, resctrl is the only kernfs based filesystem that is delegated by changing ownership. Compile tested only. Signed-off-by: Josef Bacik --- fs/resctrl/rdtgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 6b7b7daa9fd3..e7f2ec56f371 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -4451,11 +4452,18 @@ static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf) return 0; } +/* Nothing here is a cell's, whatever the modes say and whoever owns it. */ +static int rdtgroup_may_change(struct kernfs_node *kn, enum kernfs_change what) +{ + return current_cell() ? -EPERM : 0; +} + static struct kernfs_syscall_ops rdtgroup_kf_syscall_ops = { .mkdir = rdtgroup_mkdir, .rmdir = rdtgroup_rmdir, .rename = rdtgroup_rename, .show_options = rdtgroup_show_options, + .may_change = rdtgroup_may_change, }; static int rdtgroup_setup_root(struct rdt_fs_context *ctx) -- 2.55.0