From: David Engraf <david.engraf@sysgo.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
John Stultz <john.stultz@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ktime_add_ns() may overflow on 32bit architectures
Date: Tue, 19 Mar 2013 13:53:55 +0100 [thread overview]
Message-ID: <51485FE3.1020905@sysgo.com> (raw)
In-Reply-To: <1363696716.21184.45.camel@edumazet-glaptop>
Am 19.03.2013 13:38, schrieb Eric Dumazet:
> On Tue, 2013-03-19 at 13:29 +0100, David Engraf wrote:
>> Hello,
>>
>> I've triggered an overflow when using ktime_add_ns() on a 32bit
>> architecture not supporting CONFIG_KTIME_SCALAR.
>>
>> When passing a very high value for u64 nsec, e.g. 7881299347898368000
>> the do_div() function converts this value to seconds (7881299347) which
>> is still to high to pass to the ktime_set() function as long. The result
>> in my case is a negative value.
>>
>> The problem on my system occurs in the tick-sched.c,
>> tick_nohz_stop_sched_tick() when time_delta is set to
>> timekeeping_max_deferment(). The check for time_delta < KTIME_MAX is
>> valid, thus ktime_add_ns() is called with a too large value resulting in
>> a negative expire value. This leads to an endless loop in the ticker code:
>>
>> time_delta: 7881299347898368000
>> expires = ktime_add_ns(last_update, time_delta)
>> expires: negative value
>>
>> This error doesn't occurs on 64bit or architectures supporting
>> CONFIG_KTIME_SCALAR (e.g. ARM, x86-32).
>>
>> Best regards
>> - David
>>
>> Signed-off-by: David Engraf <david.engraf@sysgo.com>
>>
>
> But check already exists for 64bit arches in ktime_set()
>
Yes, but not for 32bit arches. 64-bit arches doesn't run into this
problem because ktime_add_ns() can directly calculate the result without
calling do_div() and ktime_set().
next prev parent reply other threads:[~2013-03-19 12:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-19 12:29 [PATCH] ktime_add_ns() may overflow on 32bit architectures David Engraf
2013-03-19 12:38 ` Eric Dumazet
2013-03-19 12:53 ` David Engraf [this message]
2013-04-08 20:20 ` John Stultz
2013-04-09 7:08 ` David Engraf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51485FE3.1020905@sysgo.com \
--to=david.engraf@sysgo.com \
--cc=eric.dumazet@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.