Re: [PATCH] blk-ioprio: check capabilities before promoting a cgroup to RT
From: Bart Van Assche
Date: Mon Nov 16 2026 - 14:11:00 EST
On 11/16/26 1:05 AM, Hungyu Lin wrote:
> Require CAP_SYS_ADMIN or CAP_SYS_NICE for the two policies that raise
> the priority class, like ioprio_check_cap() does. The other policies are
> left alone.
Restricting RT promotion to privileged users makes sense to me. A few
comments below.
> @@ -91,6 +92,9 @@ static ssize_t ioprio_set_prio_policy(struct kernfs_open_file *of, char *buf,
> ret = sysfs_match_string(policy_name, buf);
> if (ret < 0)
> return ret;
> + if ((ret == POLICY_PROMOTE_TO_RT || ret == POLICY_NONE_TO_RT) &&
> + !capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_NICE))
> + return -EPERM;
capable() checks the credentials of the task that calls write() rather
than the credentials of the task that opened the file. Checking the
credentials of the caller from inside a .write() callback is discouraged
because it enables confused-deputy attacks, e.g. an unprivileged user
opens io.prio.class and passes the file descriptor as stdout or stderr
to a setuid program. cgroup_release_agent_write() uses the file
credentials for this reason. Please use something like this instead:
if ((ret == POLICY_PROMOTE_TO_RT || ret == POLICY_NONE_TO_RT) &&
!file_ns_capable(of->file, &init_user_ns, CAP_SYS_ADMIN) &&
!file_ns_capable(of->file, &init_user_ns, CAP_SYS_NICE))
return -EPERM;
Additionally, please update the io.prio.class documentation in
Documentation/admin-guide/cgroup-v2.rst such that it mentions that
CAP_SYS_ADMIN or CAP_SYS_NICE is required to select the promote-to-rt
and none-to-rt policies.
Thanks,
Bart.