1. 14 6月, 2017 1 次提交
  2. 13 5月, 2017 1 次提交
  3. 15 4月, 2017 1 次提交
  4. 01 2月, 2017 1 次提交
  5. 25 12月, 2016 1 次提交
  6. 01 9月, 2016 1 次提交
    • V
      time: Avoid undefined behaviour in timespec64_add_safe() · 469e857f
      Vegard Nossum 提交于
      I ran into this:
      
          ================================================================================
          UBSAN: Undefined behaviour in kernel/time/time.c:783:2
          signed integer overflow:
          5273 + 9223372036854771711 cannot be represented in type 'long int'
          CPU: 0 PID: 17363 Comm: trinity-c0 Not tainted 4.8.0-rc1+ #88
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org
          04/01/2014
           0000000000000000 ffff88011457f8f0 ffffffff82344f50 0000000041b58ab3
           ffffffff84f98080 ffffffff82344ea4 ffff88011457f918 ffff88011457f8c8
           ffff88011457f8e0 7fffffffffffefff ffff88011457f6d8 dffffc0000000000
          Call Trace:
           [<ffffffff82344f50>] dump_stack+0xac/0xfc
           [<ffffffff82344ea4>] ? _atomic_dec_and_lock+0xc4/0xc4
           [<ffffffff8242f4c8>] ubsan_epilogue+0xd/0x8a
           [<ffffffff8242fc04>] handle_overflow+0x202/0x23d
           [<ffffffff8242fa02>] ? val_to_string.constprop.6+0x11e/0x11e
           [<ffffffff823c7837>] ? debug_smp_processor_id+0x17/0x20
           [<ffffffff8131b581>] ? __sigqueue_free.part.13+0x51/0x70
           [<ffffffff8146d4e0>] ? rcu_is_watching+0x110/0x110
           [<ffffffff8242fc4d>] __ubsan_handle_add_overflow+0xe/0x10
           [<ffffffff81476ef8>] timespec64_add_safe+0x298/0x340
           [<ffffffff81476c60>] ? timespec_add_safe+0x330/0x330
           [<ffffffff812f7990>] ? wait_noreap_copyout+0x1d0/0x1d0
           [<ffffffff8184bf18>] poll_select_set_timeout+0xf8/0x170
           [<ffffffff8184be20>] ? poll_schedule_timeout+0x2b0/0x2b0
           [<ffffffff813aa9bb>] ? __might_sleep+0x5b/0x260
           [<ffffffff833c8a87>] __sys_recvmmsg+0x107/0x790
           [<ffffffff833c8980>] ? SyS_recvmsg+0x20/0x20
           [<ffffffff81486378>] ? hrtimer_start_range_ns+0x3b8/0x1380
           [<ffffffff845f8bfb>] ? _raw_spin_unlock_irqrestore+0x3b/0x60
           [<ffffffff8148bcea>] ? do_setitimer+0x39a/0x8e0
           [<ffffffff813aa9bb>] ? __might_sleep+0x5b/0x260
           [<ffffffff833c9110>] ? __sys_recvmmsg+0x790/0x790
           [<ffffffff833c91e9>] SyS_recvmmsg+0xd9/0x160
           [<ffffffff833c9110>] ? __sys_recvmmsg+0x790/0x790
           [<ffffffff823c7853>] ? __this_cpu_preempt_check+0x13/0x20
           [<ffffffff8162f680>] ? __context_tracking_exit.part.3+0x30/0x1b0
           [<ffffffff833c9110>] ? __sys_recvmmsg+0x790/0x790
           [<ffffffff81007bd3>] do_syscall_64+0x1b3/0x4b0
           [<ffffffff845f936a>] entry_SYSCALL64_slow_path+0x25/0x25
          ================================================================================
      
      Line 783 is this:
      
      783         set_normalized_timespec64(&res, lhs.tv_sec + rhs.tv_sec,
      784                         lhs.tv_nsec + rhs.tv_nsec);
      
      In other words, since lhs.tv_sec and rhs.tv_sec are both time64_t, this
      is a signed addition which will cause undefined behaviour on overflow.
      
      Note that this is not currently a huge concern since the kernel should be
      built with -fno-strict-overflow by default, but could be a problem in the
      future, a problem with older compilers, or other compilers than gcc.
      
      The easiest way to avoid the overflow is to cast one of the arguments to
      unsigned (so the addition will be done using unsigned arithmetic).
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Signed-off-by: NVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      469e857f
  7. 20 5月, 2016 2 次提交
  8. 23 4月, 2016 1 次提交
    • B
      time: Introduce do_sys_settimeofday64() · 86d34732
      Baolin Wang 提交于
      The do_sys_settimeofday() function uses a timespec, which is not year
      2038 safe on 32bit systems.
      
      Thus this patch introduces do_sys_settimeofday64(), which allows us to
      transition users of do_sys_settimeofday() to using 64bit time types.
      
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      [jstultz: Include errno-base.h to avoid build issue on some arches]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      86d34732
  9. 29 2月, 2016 1 次提交
    • D
      Handle ISO 8601 leap seconds and encodings of midnight in mktime64() · ede5147d
      David Howells 提交于
      Handle the following ISO 8601 features in mktime64():
      
       (1) Leap seconds.
      
           Leap seconds are indicated by the seconds parameter being the value
           60.  Handle this by treating it the same as 00 of the following
           minute.
      
           It has been pointed out that a minute may contain two leap seconds.
           However, pending discussion of what that looks like and how to handle
           it, I'm not going to concern myself with it.
      
       (2) Alternate encodings of midnight.
      
           Two different encodings of midnight are permitted - 00:00:00 and
           24:00:00 - the first is midnight today and the second is midnight
           tomorrow and is exactly equivalent to the first with tomorrow's date.
      
      As it happens, we don't actually need to change mktime64() to handle either
      of these - just comment them as valid parameters.
      
      These facility will be used by the X.509 parser.  Doing it in mktime64()
      makes the policy common to the whole kernel and easier to find.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      cc: John Stultz <john.stultz@linaro.org>
      cc: Rudolf Polzer <rpolzer@google.com>
      cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      ede5147d
  10. 18 8月, 2015 2 次提交
    • B
      time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64() · 9ca30850
      Baolin Wang 提交于
      The conversion between struct timespec and jiffies is not year 2038
      safe on 32bit systems. Introduce timespec64_to_jiffies() and
      jiffies_to_timespec64() functions which use struct timespec64 to
      make it ready for 2038 issue.
      
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      9ca30850
    • K
      time: Fix nanosecond file time rounding in timespec_trunc() · de4a95fa
      Karsten Blees 提交于
      timespec_trunc() avoids rounding if granularity <= nanoseconds-per-jiffie
      (or TICK_NSEC). This optimization assumes that:
      
       1. current_kernel_time().tv_nsec is already rounded to TICK_NSEC (i.e.
          with HZ=1000 you'd get 1000000, 2000000, 3000000... but never 1000001).
          This is no longer true (probably since hrtimers introduced in 2.6.16).
      
       2. TICK_NSEC is evenly divisible by all possible granularities. This may
          be true for HZ=100, 250, 1000, but obviously not for HZ=300 /
          TICK_NSEC=3333333 (introduced in 2.6.20).
      
      Thus, sub-second portions of in-core file times are not rounded to on-disk
      granularity. I.e. file times may change when the inode is re-read from disk
      or when the file system is remounted.
      
      This affects all file systems with file time granularities > 1 ns and < 1s,
      e.g. CEPH (1000 ns), UDF (1000 ns), CIFS (100 ns), NTFS (100 ns) and FUSE
      (configurable from user mode via struct fuse_init_out.time_gran).
      
      Steps to reproduce with e.g. UDF:
      
        $ dd if=/dev/zero of=udfdisk count=10000 && mkudffs udfdisk
        $ mkdir udf && mount udfdisk udf
        $ touch udf/test && stat -c %y udf/test
        2015-06-09 10:22:56.130006767 +0200
        $ umount udf && mount udfdisk udf
        $ stat -c %y udf/test
        2015-06-09 10:22:56.130006000 +0200
      
      Remounting truncates the mtime to 1 µs.
      
      Fix the rounding in timespec_trunc() and update the documentation.
      
      timespec_trunc() is exclusively used to calculate inode's [acm]time (mostly
      via current_fs_time()), and always with super_block.s_time_gran as second
      argument. So this can safely be changed without side effects.
      
      Note: This does _not_ fix the issue for FAT's 2 second mtime resolution,
      as super_block.s_time_gran isn't prepared to handle different ctime /
      mtime / atime resolutions nor resolutions > 1 second.
      
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NKarsten Blees <blees@dcon.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      de4a95fa
  11. 29 7月, 2015 1 次提交
    • F
      jiffies: Remove HZ > USEC_PER_SEC special case · e0758676
      Frederic Weisbecker 提交于
      HZ never goes much further 1000 and a bit. And if we ever reach one tick
      per microsecond, we might be having a problem.
      
      Lets stop maintaining this special case, just leave a paranoid check.
      Reviewed-by: NRik van Riel <riel@redhat.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc; John Stultz <john.stultz@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      e0758676
  12. 10 6月, 2015 1 次提交
  13. 23 5月, 2015 1 次提交
  14. 19 5月, 2015 2 次提交
  15. 08 1月, 2015 1 次提交
  16. 05 12月, 2014 1 次提交
  17. 22 11月, 2014 1 次提交
  18. 13 9月, 2014 1 次提交
    • A
      jiffies: Fix timeval conversion to jiffies · d78c9300
      Andrew Hunter 提交于
      timeval_to_jiffies tried to round a timeval up to an integral number
      of jiffies, but the logic for doing so was incorrect: intervals
      corresponding to exactly N jiffies would become N+1. This manifested
      itself particularly repeatedly stopping/starting an itimer:
      
      setitimer(ITIMER_PROF, &val, NULL);
      setitimer(ITIMER_PROF, NULL, &val);
      
      would add a full tick to val, _even if it was exactly representable in
      terms of jiffies_ (say, the result of a previous rounding.)  Doing
      this repeatedly would cause unbounded growth in val.  So fix the math.
      
      Here's what was wrong with the conversion: we essentially computed
      (eliding seconds)
      
      jiffies = usec  * (NSEC_PER_USEC/TICK_NSEC)
      
      by using scaling arithmetic, which took the best approximation of
      NSEC_PER_USEC/TICK_NSEC with denominator of 2^USEC_JIFFIE_SC =
      x/(2^USEC_JIFFIE_SC), and computed:
      
      jiffies = (usec * x) >> USEC_JIFFIE_SC
      
      and rounded this calculation up in the intermediate form (since we
      can't necessarily exactly represent TICK_NSEC in usec.) But the
      scaling arithmetic is a (very slight) *over*approximation of the true
      value; that is, instead of dividing by (1 usec/ 1 jiffie), we
      effectively divided by (1 usec/1 jiffie)-epsilon (rounding
      down). This would normally be fine, but we want to round timeouts up,
      and we did so by adding 2^USEC_JIFFIE_SC - 1 before the shift; this
      would be fine if our division was exact, but dividing this by the
      slightly smaller factor was equivalent to adding just _over_ 1 to the
      final result (instead of just _under_ 1, as desired.)
      
      In particular, with HZ=1000, we consistently computed that 10000 usec
      was 11 jiffies; the same was true for any exact multiple of
      TICK_NSEC.
      
      We could possibly still round in the intermediate form, adding
      something less than 2^USEC_JIFFIE_SC - 1, but easier still is to
      convert usec->nsec, round in nanoseconds, and then convert using
      time*spec*_to_jiffies.  This adds one constant multiplication, and is
      not observably slower in microbenchmarks on recent x86 hardware.
      
      Tested: the following program:
      
      int main() {
        struct itimerval zero = {{0, 0}, {0, 0}};
        /* Initially set to 10 ms. */
        struct itimerval initial = zero;
        initial.it_interval.tv_usec = 10000;
        setitimer(ITIMER_PROF, &initial, NULL);
        /* Save and restore several times. */
        for (size_t i = 0; i < 10; ++i) {
          struct itimerval prev;
          setitimer(ITIMER_PROF, &zero, &prev);
          /* on old kernels, this goes up by TICK_USEC every iteration */
          printf("previous value: %ld %ld %ld %ld\n",
                 prev.it_interval.tv_sec, prev.it_interval.tv_usec,
                 prev.it_value.tv_sec, prev.it_value.tv_usec);
          setitimer(ITIMER_PROF, &prev, NULL);
        }
          return 0;
      }
      
      Cc: stable@vger.kernel.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Reviewed-by: NPaul Turner <pjt@google.com>
      Reported-by: NAaron Jacobs <jacobsa@google.com>
      Signed-off-by: NAndrew Hunter <ahh@google.com>
      [jstultz: Tweaked to apply to 3.17-rc]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      d78c9300
  19. 24 7月, 2014 3 次提交
  20. 23 6月, 2014 1 次提交
  21. 19 6月, 2013 1 次提交
  22. 16 3月, 2013 2 次提交
  23. 22 2月, 2013 1 次提交
  24. 09 2月, 2013 1 次提交
    • P
      time, Fix setting of hardware clock in NTP code · 84e345e4
      Prarit Bhargava 提交于
      At init time, if the system time is "warped" forward in warp_clock()
      it will differ from the hardware clock by sys_tz.tz_minuteswest.  This time
      difference is not taken into account when ntp updates the hardware clock,
      and this causes the system time to jump forward by this offset every reboot.
      
      The kernel must take this offset into account when writing the system time
      to the hardware clock in the ntp code.  This patch adds
      persistent_clock_is_local which indicates that an offset has been applied
      in warp_clock() and accounts for the "warp" before writing the hardware
      clock.
      
      x86 does not have this problem as rtc writes are software limited to a
      +/-15 minute window relative to the current rtc time.  Other arches, such
      as powerpc, however do a full synchronization of the system time to the
      rtc and will see this problem.
      
      [v2]: generated against tip/timers/core
      Signed-off-by: NPrarit Bhargava <prarit@redhat.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      84e345e4
  25. 25 9月, 2012 1 次提交
    • J
      time: Move update_vsyscall definitions to timekeeper_internal.h · 189374ae
      John Stultz 提交于
      Since users will need to include timekeeper_internal.h, move
      update_vsyscall definitions to timekeeper_internal.h.
      
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      189374ae
  26. 16 3月, 2012 1 次提交
  27. 31 10月, 2011 1 次提交
  28. 21 9月, 2011 1 次提交
  29. 02 2月, 2011 1 次提交
  30. 31 1月, 2011 1 次提交
  31. 26 1月, 2011 1 次提交
  32. 29 11月, 2010 1 次提交
    • J
      Kill off a bunch of warning: ‘inline’ is not at beginning of declaration · fa9f90be
      Jesper Juhl 提交于
      These warnings are spewed during a build of a 'allnoconfig' kernel
      (especially the ones from u64_stats_sync.h show up a lot) when building
      with -Wextra (which I often do)..
      They are
        a) annoying
        b) easy to get rid of.
      This patch kills them off.
      
      include/linux/u64_stats_sync.h:70:1: warning: ‘inline’ is not at beginning of declaration
      include/linux/u64_stats_sync.h:77:1: warning: ‘inline’ is not at beginning of declaration
      include/linux/u64_stats_sync.h:84:1: warning: ‘inline’ is not at beginning of declaration
      include/linux/u64_stats_sync.h:96:1: warning: ‘inline’ is not at beginning of declaration
      include/linux/u64_stats_sync.h:115:1: warning: ‘inline’ is not at beginning of declaration
      include/linux/u64_stats_sync.h:127:1: warning: ‘inline’ is not at beginning of declaration
      kernel/time.c:241:1: warning: ‘inline’ is not at beginning of declaration
      kernel/time.c:257:1: warning: ‘inline’ is not at beginning of declaration
      kernel/perf_event.c:4513:1: warning: ‘inline’ is not at beginning of declaration
      mm/page_alloc.c:4012:1: warning: ‘inline’ is not at beginning of declaration
      Signed-off-by: NJesper Juhl <jj@chaosbits.net>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      fa9f90be
  33. 27 7月, 2010 1 次提交
  34. 24 5月, 2010 1 次提交