hrtimer: Allow hrtimer::function() to free the timer
authorPeter Zijlstra <peterz@infradead.org>
Thu, 11 Jun 2015 12:46:48 +0000 (14:46 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 18 Jun 2015 22:09:56 +0000 (00:09 +0200)
commit887d9dc989eb0154492e41e7c07492edbb088ba1
tree53f3c08252d60c9ceb32fa488c1e0ab77a95b9ef
parentc4bfa3f5f906aee2e084c5b1fb15caf876338ef8
hrtimer: Allow hrtimer::function() to free the timer

Currently an hrtimer callback function cannot free its own timer
because __run_hrtimer() still needs to clear HRTIMER_STATE_CALLBACK
after it. Freeing the timer would result in a clear use-after-free.

Solve this by using a scheme similar to regular timers; track the
current running timer in hrtimer_clock_base::running.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: ktkhai@parallels.com
Cc: rostedt@goodmis.org
Cc: juri.lelli@gmail.com
Cc: pang.xunlei@linaro.org
Cc: wanpeng.li@linux.intel.com
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: umgwanakikbuti@gmail.com
Link: http://lkml.kernel.org/r/20150611124743.471563047@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/hrtimer.h
kernel/time/hrtimer.c