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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 23 Mar 2023 12:43:54 +0100
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     Daniel Golle <daniel@...rotopia.org>, linux-pm@...r.kernel.org,
        linux-mediatek@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Matthias Brugger <matthias.bgg@...il.com>
Cc:     Sam Shih <sam.shih@...iatek.com>, John Crispin <john@...ozen.org>
Subject: Re: [PATCH] cpufreq: mediatek: guard error paths to avoid kernel
 panic

Il 23/03/23 12:04, Daniel Golle ha scritto:
> Guard pointer access in error path of mtk_cpu_dvfs_info_init() to
> make sure info->proc_reg and info->sram_reg are valid pointers before
> accessing them, which would result in kernel panic e.g. in case of
> them being set to -EPROBE_DEFER.
> 
> Fixes: 4b9ceb757bbb ("cpufreq: mediatek: Enable clocks and regulators")
> Reported-by: Sam Shih <sam.shih@...iatek.com>
> Suggested-by: Sam Shih <sam.shih@...iatek.com>
> Signed-off-by: Daniel Golle <daniel@...rotopia.org>
> ---
>   drivers/cpufreq/mediatek-cpufreq.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
> index 4466d0c91a6a..980a31ddd0f2 100644
> --- a/drivers/cpufreq/mediatek-cpufreq.c
> +++ b/drivers/cpufreq/mediatek-cpufreq.c
> @@ -579,10 +579,12 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
>   	dev_pm_opp_of_cpumask_remove_table(&info->cpus);
>   
>   out_free_resources:
> -	if (regulator_is_enabled(info->proc_reg))
> -		regulator_disable(info->proc_reg);
> -	if (info->sram_reg && regulator_is_enabled(info->sram_reg))
> -		regulator_disable(info->sram_reg);
> +	if (!IS_ERR(info->proc_reg))
> +		if (regulator_is_enabled(info->proc_reg))
> +			regulator_disable(info->proc_reg);
> +	if (!IS_ERR(info->sram_reg))

For both, actually, if you suspect that (xxxx)_reg may be NULL, then you should
use IS_ERR_OR_NULL() instead...

> +		if (info->sram_reg && regulator_is_enabled(info->sram_reg))

...otherwise, here it's useless to check if it's not NULL?

Regards,
Angelo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ