cgroup/cpuset: Fix update_prstate() always returning 0 on partition errors
Subsystems (2)
PATCH 1/1 cgroup/cpuset: Fix update_prstate() always returning 0 on partition errors
From: Tao Cui <[email protected]>
update_prstate() stores the error code in cs->prs_err and transitions the partition to an invalid state, but always returns 0. The caller cpuset_partition_write() uses "return retval ?: nbytes", so the write syscall always appears to succeed from userspace even when the partition became invalid. Return -EINVAL when err is set so userspace can detect the failure immediately.
--- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cpuset.c +1 -1
@@ -2965,7 +2965,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)if (force_sd_rebuild)rebuild_sched_domains_locked ();free_tmpmasks (&tmpmask); -return 0 ; +return err ? -EINVAL :0 ; }static struct cpuset *cpuset_attach_old_cs;
Signature · 1 line
2.43.0
Kindly disregard this patch.
The issue is fixed by AI auto-testing without Signed-off-by; the tag will be included in v2.
Quoted 27 lines · Tao Cui
From: Tao Cui <[email protected]>
update_prstate()stores the error code incs->prs_errand transitions the partition to an invalid state, but always returns 0. The callercpuset_partition_write()uses "return retval ?: nbytes", so the write syscall always appears to succeed from userspace even when the partition became invalid. Return-EINVALwhen err is set so userspace can detect the failure immediately.Co-Authored-By Claude Opus 4.7 <[email protected]>--- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/cgroup/cpuset.c +1
-1@@ -2965,7 +2965,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)if (force_sd_rebuild)rebuild_sched_domains_locked ();free_tmpmasks (&tmpmask); -return 0 ; +return err ? -EINVAL :0 ; }static struct cpuset *cpuset_attach_old_cs;