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]
Date: Thu, 29 Feb 2024 20:23:23 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Shivnandan Kumar <quic_kshivnan@...cinc.com>
Cc: rafael@...nel.org, Viresh Kumar <viresh.kumar@...aro.org>, 
	Vincent Donnefort <vincent.donnefort@....com>, linux-pm@...r.kernel.org, 
	linux-kernel@...r.kernel.org, quic_pkondeti@...cinc.com, 
	quic_namajain@...cinc.com, quic_rgottimu@...cinc.com, 
	kernel <kernel@...cinc.com>, stable@...r.kernel.org
Subject: Re: [PATCH v2] cpufreq: Limit resolving a frequency to policy min/max

On Tue, Feb 27, 2024 at 10:15 AM Shivnandan Kumar
<quic_kshivnan@...cinc.com> wrote:
>
> Resolving a frequency to an efficient one should not transgress policy->max
> (which can be set for thermal reason) and policy->min. Currently there is
> possibility where scaling_cur_freq can exceed scaling_max_freq when
> scaling_max_freq is inefficient frequency. Add additional check to ensure
> that resolving a frequency will respect policy->min/max.
>
> Cc: <stable@...r.kernel.org>
> Fixes: 1f39fa0dccff ("cpufreq: Introducing CPUFREQ_RELATION_E")
> Signed-off-by: Shivnandan Kumar <quic_kshivnan@...cinc.com>
> --
>
> Changes in v2:
> -rename function name from cpufreq_table_index_is_in_limits to cpufreq_is_in_limits
> -remove redundant outer parenthesis in return statement
> -Make comment single line
>
> --
> ---
>  include/linux/cpufreq.h | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index afda5f24d3dd..7741244dee6e 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -1021,6 +1021,19 @@ static inline int cpufreq_table_find_index_c(struct cpufreq_policy *policy,
>                                                    efficiencies);
>  }
>
> +static inline bool cpufreq_is_in_limits(struct cpufreq_policy *policy,
> +                                                   int idx)
> +{
> +       unsigned int freq;
> +
> +       if (idx < 0)
> +               return false;
> +
> +       freq = policy->freq_table[idx].frequency;
> +
> +       return freq == clamp_val(freq, policy->min, policy->max);
> +}
> +
>  static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
>                                                  unsigned int target_freq,
>                                                  unsigned int relation)
> @@ -1054,7 +1067,8 @@ static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
>                 return 0;
>         }
>
> -       if (idx < 0 && efficiencies) {
> +       /* Limit frequency index to honor policy->min/max */
> +       if (!cpufreq_is_in_limits(policy, idx) && efficiencies) {
>                 efficiencies = false;
>                 goto retry;
>         }
> --

Applied (with a whitespace adjustment and changelog edits) as 6.9
material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ