From: Liav Rehana <liavr@mellanox.com>
To: <linux-kernel@vger.kernel.org>
Cc: <tglx@linutronix.de>, <john.stultz@linaro.org>,
<noamca@mellanox.com>, <eladkan@mellanox.com>,
Liav Rehana <liavr@mellanox.com>
Subject: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation.
Date: Thu, 1 Sep 2016 14:14:38 +0300 [thread overview]
Message-ID: <1472728478-3788-1-git-send-email-liavr@mellanox.com> (raw)
From: Liav Rehana <liavr@mellanox.com>
During the calculation of the nsec variable, "delta * tkr->mult" may cause
overflow to the msb, if the suspended time is too long.
In that case, we need to guarantee that the variable will not go through a
sign extension during its shift, and thus it will result in a much higher
value - close to the larget value of 64 bits.
The following commit fixes this problem, which causes the following bug:
Trying to connect through ftp to the os after a long enough suspended time
will cause the nsec variable to get a much higher value after its shift
because of sign extension, and thus the loop that follows some instructions
afterwards, implemented in the inline function __iter_div_u64_rem, will
take too long.
Signed-off-by: Liav Rehana <liavr@mellanox.com>
---
kernel/time/timekeeping.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 479d25c..ddf56a5 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -305,7 +305,7 @@ static inline s64 timekeeping_delta_to_ns(struct tk_read_base *tkr,
s64 nsec;
nsec = delta * tkr->mult + tkr->xtime_nsec;
- nsec >>= tkr->shift;
+ nsec = ((u64) nsec) >> tkr->shift;
/* If arch requires, add in get_arch_timeoffset() */
return nsec + arch_gettimeoffset();
--
1.7.1
next reply other threads:[~2016-09-01 22:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 11:14 Liav Rehana [this message]
2016-09-02 8:49 ` Thomas Gleixner
2016-09-02 18:30 ` Thomas Gleixner
2016-09-02 18:47 ` Thomas Gleixner
2016-09-04 6:40 ` Liav Rehana
2016-09-04 9:01 ` Thomas Gleixner
2016-09-04 10:03 ` Liav Rehana
2016-09-04 10:39 ` Thomas Gleixner
2016-09-07 3:22 ` John Stultz
2016-09-11 6:31 ` Liav Rehana
2016-09-21 21:12 ` John Stultz
2016-09-21 12:52 ` Liav Rehana
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=1472728478-3788-1-git-send-email-liavr@mellanox.com \
--to=liavr@mellanox.com \
--cc=eladkan@mellanox.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noamca@mellanox.com \
--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
all inboxes | Powered by JetHome®