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]
Date:   Thu, 9 Dec 2021 10:23:13 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc:     mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        bsegall@...gle.com, mgorman@...e.de, bristot@...hat.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/uclamp: potential dereference of null pointer

On Thu,  9 Dec 2021 11:31:27 +0800
Jiasheng Jiang <jiasheng@...as.ac.cn> wrote:

> The return value of kzalloc() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.
> 
> Fixes: 391e43da797a ("sched: Move all scheduler bits into kernel/sched/")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
>  kernel/sched/core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index e5858999b54d..988a4a372e14 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8125,6 +8125,8 @@ void __init sched_init(void)
>  #endif
>  	if (ptr) {
>  		ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
> +		if (!ptr)
> +			return;

If this were to happen the system would crash immediately, with or without
the return.

If you are worried about not being able to allocate ptr, then the only
reasonable fix here is

		BUG_ON(!ptr);

That way you would know exactly why your system crashed. Because just
returning would crash for other reasons and make it less debuggable.

-- Steve


>  
>  #ifdef CONFIG_FAIR_GROUP_SCHED
>  		root_task_group.se = (struct sched_entity **)ptr;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ