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] [day] [month] [year] [list]
Message-ID: <CAJZ5v0hviMc_vhnOx_mPLikAX-5X4YjZabP+F5GNH5ac8WNGcw@mail.gmail.com>
Date:   Thu, 15 Jun 2023 18:16:13 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Wyes Karny <wyes.karny@....com>
Cc:     rafael@...nel.org, viresh.kumar@...aro.org, ray.huang@....com,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        gautham.shenoy@....com
Subject: Re: [PATCH v4.1] cpufreq: Fail driver register if it has adjust_perf
 without fast_switch

On Mon, May 29, 2023 at 4:26 PM Wyes Karny <wyes.karny@....com> wrote:
>
> If fast_switch_possible flag is set by the scaling driver, the governor
> is free to select fast_switch function even if adjust_perf is set.  Some
> scaling drivers which use adjust_perf don't set fast_switch thinking
> that the governor would never fall back to fast_switch. But the governor
> can fall back to fast_switch even in runtime if frequency invariance is
> disabled due to some reason. This could crash the kernel if the driver
> didn't set the fast_switch function pointer.
>
> Therefore, fail driver registration if it has adjust_perf without
> fast_switch.
>
> Suggested-by: Rafael J. Wysocki <rafael@...nel.org>
> Suggested-by: Viresh Kumar <viresh.kumar@...aro.org>
> Signed-off-by: Wyes Karny <wyes.karny@....com>
> ---
>  drivers/cpufreq/cpufreq.c | 3 ++-
>  include/linux/cpufreq.h   | 5 ++++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6b52ebe5a890..50bbc969ffe5 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2828,7 +2828,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>              (driver_data->setpolicy && (driver_data->target_index ||
>                     driver_data->target)) ||
>              (!driver_data->get_intermediate != !driver_data->target_intermediate) ||
> -            (!driver_data->online != !driver_data->offline))
> +            (!driver_data->online != !driver_data->offline) ||
> +                (driver_data->adjust_perf && !driver_data->fast_switch))
>                 return -EINVAL;
>
>         pr_debug("trying to register driver %s\n", driver_data->name);
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 26e2eb399484..172ff51c1b2a 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -340,7 +340,10 @@ struct cpufreq_driver {
>         /*
>          * ->fast_switch() replacement for drivers that use an internal
>          * representation of performance levels and can pass hints other than
> -        * the target performance level to the hardware.
> +        * the target performance level to the hardware. This can only be set
> +        * if ->fast_switch is set too, because in those cases (under specific
> +        * conditions) scale invariance can be disabled, which causes the
> +        * schedutil governor to fall back to the latter.
>          */
>         void            (*adjust_perf)(unsigned int cpu,
>                                        unsigned long min_perf,
> --

Applied as 6.5 material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ