Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532334

Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in its calculation.

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in its calculation.
Date 2016-11-29 15:30 +0100
Message-ID <sIRzX-1bf-3@gated-at.bofh.it> (permalink)
References <sF5UR-78-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, 18 Nov 2016, John Stultz wrote:
> From: Liav Rehana <liavr@mellanox.com>
> 
> During the calculation of the nsec variable in the inline function
> timekeeping_delta_to_ns, it may undergo a sign extension if its msb
> is set just before the shift. The sign extension may, in some cases,
> gain it a value near the maximum value of the 64-bit range. This is
> bad when it is later used in a division function, such as
> __iter_div_u64_rem, where the amount of loops it will go through to
> calculate the division will be too large. One can encounter such a
> problem, for example, when trying to connect through ftp from an
> outside host to the operation system. When the OS is too overloaded,
> delta will get a high enough value for the msb of the sum
> delta * tkr->mult + tkr->xtime_nsec to be set, and so after the
> shift the nsec variable will gain a value similar to
> 0xffffffffff000000. Using a variable with such a value in the
> inline function __iter_div_u64_rem will take too long, making the
> ftp connection attempt seem to get stuck.
> The following commit fixes that chance of sign extension, while
> maintaining the type of the nsec variable as signed for other
> functions that use this variable, for possible legit negative
> time intervals.
>
> Thomas/Ingo: This is for tip:timers/urgent.

Certainly not! My objections against this still stand. See:

http://lkml.kernel.org/r/alpine.DEB.2.20.1609261956160.4915@nanos

http://lkml.kernel.org/r/alpine.DEB.2.20.1609270929170.4891@nanos

If we have legitimate use cases with a negative delta, then this patch
breaks them no matter what. See the basic C course section in the second
link.

Thanks,

	tglx

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-11-29 15:30 +0100
  Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. David Gibson <david@gibson.dropbear.id.au> - 2016-11-30 01:40 +0100
    Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-01 00:30 +0100
      Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. David Gibson <david@gibson.dropbear.id.au> - 2016-12-01 03:20 +0100
        Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-01 13:10 +0100
          Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. John Stultz <john.stultz@linaro.org> - 2016-12-01 21:30 +0100
            Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-01 21:50 +0100
              Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. John Stultz <john.stultz@linaro.org> - 2016-12-01 22:20 +0100
                Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-01 23:50 +0100
                Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. John Stultz <john.stultz@linaro.org> - 2016-12-02 00:10 +0100
                Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-02 00:20 +0100
          Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. David Gibson <david@gibson.dropbear.id.au> - 2016-12-02 00:40 +0100
            Re: [PATCH] timekeeping: Change type of nsec variable to unsigned  in its calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-12-02 09:40 +0100
              Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in  its calculation. David Gibson <david@gibson.dropbear.id.au> - 2016-12-03 01:40 +0100

csiph-web