Skip to content

Commit

Permalink
posix-cpu-timers: Always clear head pointer on dequeue
Browse files Browse the repository at this point in the history
The head pointer in struct cpu_timer is checked to be NULL in
posix_cpu_timer_del() when the delete raced with the exit cleanup. The
works correctly as long as the timer is actually dequeued via
posix_cpu_timers_exit*().

But if the timer was dequeued due to expiry the head pointer is still set
and triggers the warning.

In fact keeping the head pointer around after any dequeue is pointless as
is has no meaning at all after that.

Clear the head pointer always on dequeue and remove the unused requeue
function while at it.

Fixes: 60bda03 ("posix-cpu-timers: Utilize timerqueue for storage")
Reported-by: syzbot+55acd54b57bb4b3840a4@syzkaller.appspotmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lkml.kernel.org/r/20190905120539.707986830@linutronix.de
  • Loading branch information
Thomas Gleixner committed Sep 5, 2019
1 parent 5d2295f commit 00d9e47
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/linux/posix-timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ struct cpu_timer {
int firing;
};

static inline bool cpu_timer_requeue(struct cpu_timer *ctmr)
{
return timerqueue_add(ctmr->head, &ctmr->node);
}

static inline bool cpu_timer_enqueue(struct timerqueue_head *head,
struct cpu_timer *ctmr)
{
Expand All @@ -88,8 +83,10 @@ static inline bool cpu_timer_enqueue(struct timerqueue_head *head,

static inline void cpu_timer_dequeue(struct cpu_timer *ctmr)
{
if (!RB_EMPTY_NODE(&ctmr->node.node))
if (ctmr->head) {
timerqueue_del(ctmr->head, &ctmr->node);
ctmr->head = NULL;
}
}

static inline u64 cpu_timer_getexpires(struct cpu_timer *ctmr)
Expand Down

0 comments on commit 00d9e47

Please sign in to comment.