mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
	Ingo Molnar <mingo@kernel.org>,
	Prarit Bhargava <prarit@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <john.stultz@linaro.org>
Subject: [PATCH 2/4] time: Fix casting issue in timekeeping_forward_now
Date: Tue, 21 Aug 2012 20:30:47 -0400	[thread overview]
Message-ID: <1345595449-34965-3-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1345595449-34965-1-git-send-email-john.stultz@linaro.org>

From: Andreas Schwab <schwab@linux-m68k.org>

arch_gettimeoffset returns a u32 value which when shifted by tk->shift can
overflow.  Cast it to u64 first.

This issue was introduced with 1e75fa8be9fb61e1af46b5b3b176347a4c958ca1

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 kernel/time/timekeeping.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 258164a..1dbf80e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -277,7 +277,7 @@ static void timekeeping_forward_now(struct timekeeper *tk)
 	tk->xtime_nsec += cycle_delta * tk->mult;
 
 	/* If arch requires, add in gettimeoffset() */
-	tk->xtime_nsec += arch_gettimeoffset() << tk->shift;
+	tk->xtime_nsec += (u64)arch_gettimeoffset() << tk->shift;
 
 	tk_normalize_xtime(tk);
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-08-22  0:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22  0:30 [PATCH 0/4] Time fixes for 3.6 John Stultz
2012-08-22  0:30 ` [PATCH 1/4] time: Ensure we normalize the timekeeper in tk_xtime_add John Stultz
2012-08-22  8:50   ` [tip:timers/urgent] " tip-bot for John Stultz
2012-08-22  0:30 ` John Stultz [this message]
2012-08-22  8:51   ` [tip:timers/urgent] time: Fix casting issue in timekeeping_forward_now tip-bot for Andreas Schwab
2012-08-22  0:30 ` [PATCH 3/4] time: Avoid potential shift-overflow with large shift values John Stultz
2012-08-22  8:11   ` Geert Uytterhoeven
2012-08-22  8:52   ` [tip:timers/urgent] time: Avoid potential shift overflow " tip-bot for John Stultz
2012-08-22  0:30 ` [PATCH 4/4] time: Avoid making adjustments if we havne't accumulated anything John Stultz
2012-08-22  8:52   ` [tip:timers/urgent] time: Avoid making adjustments if we haven' t " tip-bot for John Stultz

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=1345595449-34965-3-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=schwab@linux-m68k.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

Powered by JetHome