lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aUErd53BltjN3XaB@gpd4>
Date: Tue, 16 Dec 2025 10:50:47 +0100
From: Andrea Righi <arighi@...dia.com>
To: Liang Jie <buaajxlj@....com>
Cc: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>,
	Changwoo Min <changwoo@...lia.com>, Ingo Molnar <mingo@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Juri Lelli <juri.lelli@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
	Valentin Schneider <vschneid@...hat.com>,
	"open list:SCHEDULER - SCHED_EXT" <sched-ext@...ts.linux.dev>,
	"open list:SCHEDULER" <linux-kernel@...r.kernel.org>,
	liangjie@...iang.com, kernel test robot <lkp@...el.com>,
	Dan Carpenter <error27@...il.com>
Subject: Re: [PATCH] sched_ext: fix uninitialized ret on alloc_percpu()
 failure

On Tue, Dec 16, 2025 at 05:39:55PM +0800, Liang Jie wrote:
> From: Liang Jie <liangjie@...iang.com>
> 
> Smatch reported:
> 
>   kernel/sched/ext.c:5332 scx_alloc_and_add_sched() warn: passing zero to 'ERR_PTR'
> 
> In scx_alloc_and_add_sched(), the alloc_percpu() failure path jumps to
> err_free_gdsqs without initializing @ret. That can lead to returning
> ERR_PTR(0), which violates the ERR_PTR() convention and confuses
> callers.
> 
> Set @ret to -ENOMEM before jumping to the error path when
> alloc_percpu() fails.
> 
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/r/202512141601.yAXDAeA9-lkp@intel.com/
> Reported-by: Dan Carpenter <error27@...il.com>
> Fixes: c201ea1578d3 ("sched_ext: Move event_stats_cpu into scx_sched")
> Signed-off-by: Liang Jie <liangjie@...iang.com>

Makes sense to me, good catch.

Reviewed-by: Andrea Righi <arighi@...dia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 05f5a49e9649..8ea243b04dc9 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -4761,8 +4761,10 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops)
>  	}
>  
>  	sch->pcpu = alloc_percpu(struct scx_sched_pcpu);
> -	if (!sch->pcpu)
> +	if (!sch->pcpu) {
> +		ret = -ENOMEM;
>  		goto err_free_gdsqs;
> +	}
>  
>  	sch->helper = kthread_run_worker(0, "sched_ext_helper");
>  	if (IS_ERR(sch->helper)) {
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ