2024-02-29 10:13:16

by Kamalesh Babulal

[permalink] [raw]
Subject: [PATCH] cgroup/cpuset: Fix retval in update_cpumask()

The update_cpumask(), checks for newly requested cpumask by calling
validate_change(), which returns an error on passing an invalid set
of cpu(s). Independent of the error returned, update_cpumask() always
returns zero, suppressing the error and returning success to the user
on writing an invalid cpu range for a cpuset. Fix it by returning
retval instead, which is returned by validate_change().

Fixes: 99fe36ba6fc1 ("cgroup/cpuset: Improve temporary cpumasks handling")
Signed-off-by: Kamalesh Babulal <[email protected]>
---
kernel/cgroup/cpuset.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index ba36c073304a..2ddbfaa4efa9 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2562,7 +2562,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
update_partition_sd_lb(cs, old_prs);
out_free:
free_cpumasks(NULL, &tmp);
- return 0;
+ return retval;
}

/**

base-commit: cf1182944c7cc9f1c21a8a44e0d29abe12527412
--
2.44.0



2024-02-29 14:32:03

by Waiman Long

[permalink] [raw]
Subject: Re: [PATCH] cgroup/cpuset: Fix retval in update_cpumask()


On 2/29/24 05:11, Kamalesh Babulal wrote:
> The update_cpumask(), checks for newly requested cpumask by calling
> validate_change(), which returns an error on passing an invalid set
> of cpu(s). Independent of the error returned, update_cpumask() always
> returns zero, suppressing the error and returning success to the user
> on writing an invalid cpu range for a cpuset. Fix it by returning
> retval instead, which is returned by validate_change().
>
> Fixes: 99fe36ba6fc1 ("cgroup/cpuset: Improve temporary cpumasks handling")
> Signed-off-by: Kamalesh Babulal <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index ba36c073304a..2ddbfaa4efa9 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2562,7 +2562,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
> update_partition_sd_lb(cs, old_prs);
> out_free:
> free_cpumasks(NULL, &tmp);
> - return 0;
> + return retval;
> }
>
> /**
>
> base-commit: cf1182944c7cc9f1c21a8a44e0d29abe12527412

LGTM, thanks for the fix.

Reviewed-by: Waiman Long <[email protected]>


2024-02-29 20:45:14

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH] cgroup/cpuset: Fix retval in update_cpumask()

On Thu, Feb 29, 2024 at 03:41:14PM +0530, Kamalesh Babulal wrote:
> The update_cpumask(), checks for newly requested cpumask by calling
> validate_change(), which returns an error on passing an invalid set
> of cpu(s). Independent of the error returned, update_cpumask() always
> returns zero, suppressing the error and returning success to the user
> on writing an invalid cpu range for a cpuset. Fix it by returning
> retval instead, which is returned by validate_change().
>
> Fixes: 99fe36ba6fc1 ("cgroup/cpuset: Improve temporary cpumasks handling")
> Signed-off-by: Kamalesh Babulal <[email protected]>

Applied to cgroup/for-6.8-fixes.

Thanks.

--
tejun