[PATCH RFC v3 27/90] cells: add the "budget" slot

From: Josef Bacik

Date: Thu Nov 05 2026 - 10:52:11 EST


CELL_SET_FD with the key "budget" takes a file descriptor for a cgroup2
directory and makes that cgroup the budget of the cell.

Holding the cellfd gives authority over the cell, but not over the things
that are put into it. So cgroup_cell_budget_get() checks at this point
whether the caller may use the cgroup.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
kernel/cell/slots.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/kernel/cell/slots.c b/kernel/cell/slots.c
index 905672db9936..3f74b4640334 100644
--- a/kernel/cell/slots.c
+++ b/kernel/cell/slots.c
@@ -31,6 +31,21 @@ static int cell_set_hostname(struct cell *cell, const char *val)
return 0;
}

+/* A cgroup2 directory. Judged against whoever fills the slot, here and now. */
+static int cell_set_budget(struct cell *cell, struct file *file)
+{
+ struct cgroup *cgrp;
+
+ if (cell->budget)
+ return -EBUSY;
+ cgrp = cgroup_cell_budget_get(file, &cell->budget_uid, &cell->budget_gid);
+ if (IS_ERR(cgrp))
+ return PTR_ERR(cgrp);
+ cell->budget = cgrp;
+ cell->budget_id = cgroup_id(cgrp);
+ return 0;
+}
+
static int cell_set_string(struct cell *cell, const char *key, const char *val)
{
if (!strcmp(key, "hostname"))
@@ -46,6 +61,8 @@ static int cell_set_binary(struct cell *cell, const char *key,

static int cell_set_fd(struct cell *cell, const char *key, struct file *file)
{
+ if (!strcmp(key, "budget"))
+ return cell_set_budget(cell, file);
return -EINVAL;
}


--
2.55.0