Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1522416
| From | Laurent Vivier <lvivier@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() |
| Date | 2016-11-15 09:00 +0100 |
| Message-ID | <sDGOR-22f-3@gated-at.bofh.it> (permalink) |
| References | <sDvqp-2Sn-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 14/11/2016 20:42, Chris Metcalf wrote:
> This bugfix was originally made in commit 35a4933a8959 ("time:
> Avoid signed overflow in timekeeping_get_ns()"). When the code was
> refactored in commit 6bd58f09e1d8 ("time: Add cycles to nanoseconds
> translation") the signed overflow fix was lost. Re-introduce it.
>
> Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
> ---
> I happened to be looking for an unrelated fix, found this code,
> realized the tip code didn't match the fixed code, and
> backtracked to where it had gone away.
>
> kernel/time/timekeeping.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 37dec7e3db43..57926bc7b7f3 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -304,8 +304,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 = (delta * tkr->mult + tkr->xtime_nsec) >> tkr->shift;
>
> /* If arch requires, add in get_arch_timeoffset() */
> return nsec + arch_gettimeoffset();
>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() Chris Metcalf <cmetcalf@mellanox.com> - 2016-11-14 20:50 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() John Stultz <john.stultz@linaro.org> - 2016-11-14 21:00 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() Thomas Gleixner <tglx@linutronix.de> - 2016-11-15 23:00 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() John Stultz <john.stultz@linaro.org> - 2016-11-15 23:10 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() John Stultz <john.stultz@linaro.org> - 2016-11-16 02:20 +0100
[PATCH v2] time: Avoid signed overflow in timekeeping_delta_to_ns() Chris Metcalf <cmetcalf@mellanox.com> - 2016-11-16 22:30 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() David Gibson <david@gibson.dropbear.id.au> - 2016-11-15 03:50 +0100
Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns() Laurent Vivier <lvivier@redhat.com> - 2016-11-15 09:00 +0100
csiph-web