<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/time.h, branch v3.2.78</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.78</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.78'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2015-02-20T00:49:34Z</updated>
<entry>
<title>time: settimeofday: Validate the values of tv from user</title>
<updated>2015-02-20T00:49:34Z</updated>
<author>
<name>Sasha Levin</name>
<email>sasha.levin@oracle.com</email>
</author>
<published>2014-12-04T00:22:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1751fde0bb621f9d05dc76c7a0045b70b88918c2'/>
<id>urn:sha1:1751fde0bb621f9d05dc76c7a0045b70b88918c2</id>
<content type='text'>
commit 6ada1fc0e1c4775de0e043e1bd3ae9d065491aa5 upstream.

An unvalidated user input is multiplied by a constant, which can result in
an undefined behaviour for large values. While this is validated later,
we should avoid triggering undefined behaviour.

Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
[jstultz: include trivial milisecond-&gt;microsecond correction noticed
by Andy]
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>time: Move ktime_t overflow checking into timespec_valid_strict</title>
<updated>2012-09-19T14:05:00Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2012-08-31T17:30:06Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=63180c8a56b254148c28762b200139dcaf92a73d'/>
<id>urn:sha1:63180c8a56b254148c28762b200139dcaf92a73d</id>
<content type='text'>
This is a -stable backport of cee58483cf56e0ba355fdd97ff5e8925329aa936

Andreas Bombe reported that the added ktime_t overflow checking added to
timespec_valid in commit 4e8b14526ca7 ("time: Improve sanity checking of
timekeeping inputs") was causing problems with X.org because it caused
timeouts larger then KTIME_T to be invalid.

Previously, these large timeouts would be clamped to KTIME_MAX and would
never expire, which is valid.

This patch splits the ktime_t overflow checking into a new
timespec_valid_strict function, and converts the timekeeping codes
internal checking to use this more strict function.

Reported-and-tested-by: Andreas Bombe &lt;aeb@debian.org&gt;
Cc: Zhouping Liu &lt;zliu@redhat.com&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Linux Kernel &lt;linux-kernel@vger.kernel.org&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>time: Improve sanity checking of timekeeping inputs</title>
<updated>2012-09-19T14:04:59Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2012-08-08T19:36:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8dd006cdafa7c955f6f4c66d25564d90aa29af1d'/>
<id>urn:sha1:8dd006cdafa7c955f6f4c66d25564d90aa29af1d</id>
<content type='text'>
This is a -stable backport of 4e8b14526ca7fb046a81c94002c1c43b6fdf0e9b

Unexpected behavior could occur if the time is set to a value large
enough to overflow a 64bit ktime_t (which is something larger then the
year 2262).

Also unexpected behavior could occur if large negative offsets are
injected via adjtimex.

So this patch improves the sanity check timekeeping inputs by
improving the timespec_valid() check, and then makes better use of
timespec_valid() to make sure we don't set the time to an invalid
negative value or one that overflows ktime_t.

Note: This does not protect from setting the time close to overflowing
ktime_t and then letting natural accumulation cause the overflow.

Reported-by: CAI Qian &lt;caiqian@redhat.com&gt;
Reported-by: Sasha Levin &lt;levinsasha928@gmail.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: Zhouping Liu &lt;zliu@redhat.com&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: http://lkml.kernel.org/r/1344454580-17031-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Linux Kernel &lt;linux-kernel@vger.kernel.org&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>timers: Posix interface for alarm-timers</title>
<updated>2011-04-26T21:01:46Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-01-11T17:54:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9a7adcf5c6dea63d2e47e6f6d2f7a6c9f48b9337'/>
<id>urn:sha1:9a7adcf5c6dea63d2e47e6f6d2f7a6c9f48b9337</id>
<content type='text'>
This patch exposes alarm-timers to userland via the posix clock
and timers interface, using two new clockids: CLOCK_REALTIME_ALARM
and CLOCK_BOOTTIME_ALARM. Both clockids behave identically to
CLOCK_REALTIME and CLOCK_BOOTTIME, respectively, but timers
set against the _ALARM suffixed clockids will wake the system if
it is suspended.

Some background can be found here:
	https://lwn.net/Articles/429925/

The concept for Alarm-timers was inspired by the Android Alarm
driver (by Arve Hjønnevåg) found in the Android kernel tree.

See: http://android.git.kernel.org/?p=kernel/common.git;a=blob;f=drivers/rtc/alarm.c;h=1250edfbdf3302f5e4ea6194847c6ef4bb7beb1c;hb=android-2.6.36

While the in-kernel interface is pretty similar between
alarm-timers and Android alarm driver, the user-space interface
for the Android alarm driver is via ioctls to a new char device.
As mentioned above, I've instead chosen to export this functionality
via the posix interface, as it seemed a little simpler and avoids
creating duplicate interfaces to things like CLOCK_REALTIME and
CLOCK_MONOTONIC under alternate names (ie:ANDROID_ALARM_RTC and
ANDROID_ALARM_SYSTEMTIME).

The semantics of the Android alarm driver are different from what
this posix interface provides. For instance, threads other then
the thread waiting on the Android alarm driver are able to modify
the alarm being waited on. Also this interface does not allow
the same wakelock semantics that the Android driver provides
(ie: kernel takes a wakelock on RTC alarm-interupt, and holds it
through process wakeup, and while the process runs, until the
process either closes the char device or calls back in to wait
on a new alarm).

One potential way to implement similar semantics may be via
the timerfd infrastructure, but this needs more research.

There may also need to be some sort of sysfs system level policy
hooks that allow alarm timers to be disabled to keep them
from firing at inappropriate times (ie: laptop in a well insulated
bag, mid-flight).

CC: Arve Hjønnevåg &lt;arve@android.com&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
CC: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>time: Add timekeeping_inject_sleeptime</title>
<updated>2011-04-26T21:01:41Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-04-01T21:32:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=304529b1b6f8612ccbb4582e997051b48b94f4a4'/>
<id>urn:sha1:304529b1b6f8612ccbb4582e997051b48b94f4a4</id>
<content type='text'>
Some platforms cannot implement read_persistent_clock, as
their RTC devices are only accessible when interrupts are enabled.
This keeps them from being used by the timekeeping code on resume
to measure the time in suspend.

The RTC layer tries to work around this, by calling do_settimeofday
on resume after irqs are reenabled to set the time properly. However,
this only corrects CLOCK_REALTIME, and does not properly adjust
the sleep time value. This causes btime in /proc/stat to be incorrect
as well as making the new CLOCK_BOTTTIME inaccurate.

This patch resolves the issue by introducing a new timekeeping hook
to allow the RTC layer to inject the sleep time on resume.

The code also checks to make sure that read_persistent_clock is
nonfunctional before setting the sleep time, so that should the RTC's
HCTOSYS option be configured in on a system that does support
read_persistent_clock we will not increase the total_sleep_time twice.

CC: Arve Hjønnevåg &lt;arve@android.com&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>timers: Add CLOCK_BOOTTIME hrtimer base</title>
<updated>2011-02-21T20:53:08Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-02-15T18:45:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=70a08cca1227dc31c784ec930099a4417a06e7d0'/>
<id>urn:sha1:70a08cca1227dc31c784ec930099a4417a06e7d0</id>
<content type='text'>
CLOCK_MONOTONIC stops while the system is in suspend. This is because
to applications system suspend is invisible. However, there is a
growing set of applications that are wanting to be suspend-aware,
but do not want to deal with the complications of CLOCK_REALTIME
(which might jump around if settimeofday is called).

For these applications, I propose a new clockid: CLOCK_BOOTTIME.
CLOCK_BOOTTIME is idential to CLOCK_MONOTONIC, except it also
includes any time spent in suspend.

This patch add hrtimer base for CLOCK_BOOTTIME, using
get_monotonic_boottime/ktime_get_boottime, to allow
in kernel users to set timers against.

CC: Jamie Lokier &lt;jamie@shareable.org&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
CC: Alexander Shishkin &lt;virtuoso@slind.org&gt;
CC: Arve Hjønnevåg &lt;arve@android.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>time: Extend get_xtime_and_monotonic_offset() to also return sleep</title>
<updated>2011-02-21T20:53:07Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-02-15T02:43:08Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=314ac37150011ebb398f522db528d2dbcc611189'/>
<id>urn:sha1:314ac37150011ebb398f522db528d2dbcc611189</id>
<content type='text'>
Extend get_xtime_and_monotonic_offset to
get_xtime_and_monotonic_and_sleep_offset().

CC: Jamie Lokier &lt;jamie@shareable.org&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
CC: Alexander Shishkin &lt;virtuoso@slind.org&gt;
CC: Arve Hjønnevåg &lt;arve@android.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>time: Introduce get_monotonic_boottime and ktime_get_boottime</title>
<updated>2011-02-21T20:53:05Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-02-15T01:52:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=abb3a4ea2e0ea7114a4475745da2f32bd9ad5b73'/>
<id>urn:sha1:abb3a4ea2e0ea7114a4475745da2f32bd9ad5b73</id>
<content type='text'>
This adds new functions that return the monotonic time since boot
(in other words, CLOCK_MONOTONIC + suspend time).

CC: Jamie Lokier &lt;jamie@shareable.org&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
CC: Alexander Shishkin &lt;virtuoso@slind.org&gt;
CC: Arve Hjønnevåg &lt;arve@android.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>time: Introduce timekeeping_inject_offset</title>
<updated>2011-02-02T14:28:18Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2011-02-01T13:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c528f7c6c208f1fae6b4025957173dec045e5f21'/>
<id>urn:sha1:c528f7c6c208f1fae6b4025957173dec045e5f21</id>
<content type='text'>
This adds a kernel-internal timekeeping interface to add or subtract
a fixed amount from CLOCK_REALTIME. This makes it so kernel users or
interfaces trying to do so do not have to read the time, then add an
offset and then call settimeofday(), which adds some extra error in
comparision to just simply adding the offset in the kernel timekeeping
core.

Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Richard Cochran &lt;richard.cochran@omicron.at&gt;
LKML-Reference: &lt;20110201134419.584311693@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>time: Correct the *settime* parameters</title>
<updated>2011-02-02T14:28:11Z</updated>
<author>
<name>Richard Cochran</name>
<email>richard.cochran@omicron.at</email>
</author>
<published>2011-02-01T13:50:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1e6d767924c74929c0cfe839ae8f37bcee9e544e'/>
<id>urn:sha1:1e6d767924c74929c0cfe839ae8f37bcee9e544e</id>
<content type='text'>
Both settimeofday() and clock_settime() promise with a 'const'
attribute not to alter the arguments passed in. This patch adds the
missing 'const' attribute into the various kernel functions
implementing these calls.

Signed-off-by: Richard Cochran &lt;richard.cochran@omicron.at&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;20110201134417.545698637@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
</feed>
