]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
posix-timers: Sanitize overrun handling
authorThomas Gleixner <tglx@linutronix.de>
Tue, 26 Jun 2018 13:21:32 +0000 (15:21 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 16 Dec 2018 22:09:45 +0000 (22:09 +0000)
commitf795b11fdc99a3d4d7d6b9d48c5e44e17c287a27
treec141d9a8fe89fa414458010dcfefcea419521872
parent921c1539170bf690cad59b3dbebf7d46843d28e2
posix-timers: Sanitize overrun handling

commit 78c9c4dfbf8c04883941445a195276bb4bb92c76 upstream.

The posix timer overrun handling is broken because the forwarding functions
can return a huge number of overruns which does not fit in an int. As a
consequence timer_getoverrun(2) and siginfo::si_overrun can turn into
random number generators.

The k_clock::timer_forward() callbacks return a 64 bit value now. Make
k_itimer::ti_overrun[_last] 64bit as well, so the kernel internal
accounting is correct. 3Remove the temporary (int) casts.

Add a helper function which clamps the overrun value returned to user space
via timer_getoverrun(2) or siginfo::si_overrun limited to a positive value
between 0 and INT_MAX. INT_MAX is an indicator for user space that the
overrun value has been clamped.

Reported-by: Team OWL337 <icytxw@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Link: https://lkml.kernel.org/r/20180626132705.018623573@linutronix.de
[bwh: Backported to 3.16: adjust filenames, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/linux/posix-timers.h
kernel/posix-cpu-timers.c
kernel/posix-timers.c