* [PATCH] cpufreq: schedutil: Fix covert rate_limit_us to freq_update_delay_ns overflow
@ 2019-07-08 8:46 ZhangXiaoxu
2019-07-08 9:37 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: ZhangXiaoxu @ 2019-07-08 8:46 UTC (permalink / raw)
To: rjw, viresh.kumar, mingo, peterz, linux-pm, zhangxiaoxu5
When covert rate_limit_us to freq_update_delay_ns, it maybe overflow
and lead an undefined behavior.
So, limit the rate_limit_us to UINT_MAX / NSEC_PER_USEC.
Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
---
kernel/sched/cpufreq_schedutil.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 962cf34..01e05f3 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -590,6 +590,9 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t count
if (kstrtouint(buf, 10, &rate_limit_us))
return -EINVAL;
+ if (rate_limit_us > UINT_MAX / NSEC_PER_USEC)
+ return -EINVAL;
+
tunables->rate_limit_us = rate_limit_us;
list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook)
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: schedutil: Fix covert rate_limit_us to freq_update_delay_ns overflow
2019-07-08 8:46 [PATCH] cpufreq: schedutil: Fix covert rate_limit_us to freq_update_delay_ns overflow ZhangXiaoxu
@ 2019-07-08 9:37 ` Viresh Kumar
2019-07-08 10:47 ` zhangxiaoxu (A)
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2019-07-08 9:37 UTC (permalink / raw)
To: ZhangXiaoxu; +Cc: rjw, mingo, peterz, linux-pm
On 08-07-19, 16:46, ZhangXiaoxu wrote:
> When covert rate_limit_us to freq_update_delay_ns, it maybe overflow
> and lead an undefined behavior.
freq_update_delay_ns is s64, still overflow can happen ?
> So, limit the rate_limit_us to UINT_MAX / NSEC_PER_USEC.
>
> Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
> ---
> kernel/sched/cpufreq_schedutil.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 962cf34..01e05f3 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -590,6 +590,9 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t count
> if (kstrtouint(buf, 10, &rate_limit_us))
> return -EINVAL;
>
> + if (rate_limit_us > UINT_MAX / NSEC_PER_USEC)
> + return -EINVAL;
> +
> tunables->rate_limit_us = rate_limit_us;
>
> list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook)
> --
> 2.7.4
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: schedutil: Fix covert rate_limit_us to freq_update_delay_ns overflow
2019-07-08 9:37 ` Viresh Kumar
@ 2019-07-08 10:47 ` zhangxiaoxu (A)
0 siblings, 0 replies; 3+ messages in thread
From: zhangxiaoxu (A) @ 2019-07-08 10:47 UTC (permalink / raw)
To: Viresh Kumar; +Cc: rjw, mingo, peterz, linux-pm
在 2019/7/8 17:37, Viresh Kumar 写道:
> On 08-07-19, 16:46, ZhangXiaoxu wrote:
>> When covert rate_limit_us to freq_update_delay_ns, it maybe overflow
>> and lead an undefined behavior.
>
> freq_update_delay_ns is s64, still overflow can happen ?
It will not happened. sorry for my misunderstander :(
>
>> So, limit the rate_limit_us to UINT_MAX / NSEC_PER_USEC.
>>
>> Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
>> ---
>> kernel/sched/cpufreq_schedutil.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
>> index 962cf34..01e05f3 100644
>> --- a/kernel/sched/cpufreq_schedutil.c
>> +++ b/kernel/sched/cpufreq_schedutil.c
>> @@ -590,6 +590,9 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t count
>> if (kstrtouint(buf, 10, &rate_limit_us))
>> return -EINVAL;
>>
>> + if (rate_limit_us > UINT_MAX / NSEC_PER_USEC)
>> + return -EINVAL;
>> +
>> tunables->rate_limit_us = rate_limit_us;
>>
>> list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook)
>> --
>> 2.7.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-08 10:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 8:46 [PATCH] cpufreq: schedutil: Fix covert rate_limit_us to freq_update_delay_ns overflow ZhangXiaoxu
2019-07-08 9:37 ` Viresh Kumar
2019-07-08 10:47 ` zhangxiaoxu (A)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).