]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
posix-timers: Sanitize overrun handling
authorThomas Gleixner <tglx@linutronix.de>
Tue, 27 Nov 2018 05:23:16 +0000 (00:23 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 6 Dec 2018 13:43:20 +0000 (14:43 +0100)
commit4729028b88966b5e7f7b084eb815d5d5183bccf5
tree2808d90ea70d17468888941a60be55f2e3865019
parent76cc4343a0136b070c1edcb4b4ba69a5c3044b47
posix-timers: Sanitize overrun handling

CVE-2018-12896

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
(cherry picked from commit 78c9c4dfbf8c04883941445a195276bb4bb92c76)
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
include/linux/posix-timers.h
kernel/time/posix-cpu-timers.c
kernel/time/posix-timers.c