public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Engraf <david.engraf@sysgo.com>
To: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ktime_add_ns() may overflow on 32bit architectures
Date: Tue, 09 Apr 2013 09:08:08 +0200	[thread overview]
Message-ID: <5163BE58.3090206@sysgo.com> (raw)
In-Reply-To: <51632673.8030603@linaro.org>

Am 08.04.2013 22:20, schrieb John Stultz:
> On 03/19/2013 05:29 AM, 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).
>
> Sorry, this fell through the cracks. I see Andrew caught it, but I've
> queued for 3.10 in my tree as well.
>
> This should be tagged for -stable as well, no?

Yes, please tag it for -stable as well because I had the problem with 
kernel 3.0 and it can overflow on all current version.

Best regards
- David

> thanks
> -john
>


      reply	other threads:[~2013-04-09  7:08 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
2013-04-08 20:20 ` John Stultz
2013-04-09  7:08   ` David Engraf [this message]

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=5163BE58.3090206@sysgo.com \
    --to=david.engraf@sysgo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox