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]
Message-ID: <da2a154a-6a97-4e87-8914-343643824b5b@huawei.com>
Date:   Thu, 25 Apr 2019 16:16:29 +0800
From:   Xie XiuQi <xiexiuqi@...wei.com>
To:     Peter Zijlstra <peterz@...radead.org>
CC:     <mingo@...hat.com>, <linux-kernel@...r.kernel.org>,
        <cj.chengjian@...wei.com>
Subject: Re: [PATCH] sched: fix a potential divide error

Hi Peter,

On 2019/4/25 16:00, Peter Zijlstra wrote:
> On Thu, Apr 25, 2019 at 11:52:28AM +0800, Xie XiuQi wrote:
>> On 2019/4/24 2:44, Peter Zijlstra wrote:
> 
>>> I'll try and come up with a better Changelog tomorrow.
> 
> I actually did, but forgot to send out. I have the below.
> Does that work for you?

It works for me, thank you very much.

> 
> ---
> Subject: sched/numa: Fix a possible divide-by-zero
> From: Xie XiuQi <xiexiuqi@...wei.com>
> Date: Sat, 20 Apr 2019 16:34:16 +0800
> 
> sched_clock_cpu() may not be consistent between CPUs. If a task
> migrates to another CPU, then se.exec_start is set to that CPU's
> rq_clock_task() by update_stats_curr_start(). Specifically, the new
> value might be before the old value due to clock skew.
> 
> So then if in numa_get_avg_runtime() the expression:
> 
>   'now - p->last_task_numa_placement'
> 
> ends up as -1, then the divider '*period + 1' in task_numa_placement()
> is 0 and things go bang. Similar to update_curr(), check if time goes
> backwards to avoid this.
> 
> Cc: mingo@...hat.com
> Cc: cj.chengjian@...wei.com
> Signed-off-by: Xie XiuQi <xiexiuqi@...wei.com>
> [peterz: simplified changelog]
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> Link: https://lkml.kernel.org/r/20190420083416.170446-1-xiexiuqi@huawei.com
> ---
>  kernel/sched/fair.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2007,6 +2007,10 @@ static u64 numa_get_avg_runtime(struct t
>  	if (p->last_task_numa_placement) {
>  		delta = runtime - p->last_sum_exec_runtime;
>  		*period = now - p->last_task_numa_placement;
> +
> +		/* Avoid backward, and prevent potential divide error */
> +		if (unlikely((s64)*period < 0))
> +			*period = 0;
>  	} else {
>  		delta = p->se.avg.load_sum;
>  		*period = LOAD_AVG_MAX;
> 
> .
> 

-- 
Thanks,
Xie XiuQi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ