Skip to content

Commit d5ca327

Browse files
committed
Merge tag 'timers-urgent-2020-04-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "Two timer subsystem fixes: - Prevent a use after free in the new lockdep state tracking for hrtimers - Add missing parenthesis in the VF pit timer driver" * tag 'timers-urgent-2020-04-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: clocksource/drivers/timer-vf-pit: Add missing parenthesis hrtimer: Don't dereference the hrtimer pointer after the callback
2 parents e5adbd6 + 760a537 commit d5ca327

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

drivers/clocksource/timer-vf-pit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int __init pit_clockevent_init(unsigned long rate, int irq)
129129
__raw_writel(PITTFLG_TIF, clkevt_base + PITTFLG);
130130

131131
BUG_ON(request_irq(irq, pit_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
132-
"VF pit timer", &clockevent_pit);
132+
"VF pit timer", &clockevent_pit));
133133

134134
clockevent_pit.cpumask = cpumask_of(0);
135135
clockevent_pit.irq = irq;

include/linux/irqflags.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,21 @@ do { \
5858
} while (0)
5959

6060
# define lockdep_hrtimer_enter(__hrtimer) \
61-
do { \
62-
if (!__hrtimer->is_hard) \
63-
current->irq_config = 1; \
64-
} while (0)
65-
66-
# define lockdep_hrtimer_exit(__hrtimer) \
67-
do { \
68-
if (!__hrtimer->is_hard) \
61+
({ \
62+
bool __expires_hardirq = true; \
63+
\
64+
if (!__hrtimer->is_hard) { \
65+
current->irq_config = 1; \
66+
__expires_hardirq = false; \
67+
} \
68+
__expires_hardirq; \
69+
})
70+
71+
# define lockdep_hrtimer_exit(__expires_hardirq) \
72+
do { \
73+
if (!__expires_hardirq) \
6974
current->irq_config = 0; \
70-
} while (0)
75+
} while (0)
7176

7277
# define lockdep_posixtimer_enter() \
7378
do { \
@@ -102,8 +107,8 @@ do { \
102107
# define lockdep_hardirq_exit() do { } while (0)
103108
# define lockdep_softirq_enter() do { } while (0)
104109
# define lockdep_softirq_exit() do { } while (0)
105-
# define lockdep_hrtimer_enter(__hrtimer) do { } while (0)
106-
# define lockdep_hrtimer_exit(__hrtimer) do { } while (0)
110+
# define lockdep_hrtimer_enter(__hrtimer) false
111+
# define lockdep_hrtimer_exit(__context) do { } while (0)
107112
# define lockdep_posixtimer_enter() do { } while (0)
108113
# define lockdep_posixtimer_exit() do { } while (0)
109114
# define lockdep_irq_work_enter(__work) do { } while (0)

kernel/time/hrtimer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
14801480
unsigned long flags) __must_hold(&cpu_base->lock)
14811481
{
14821482
enum hrtimer_restart (*fn)(struct hrtimer *);
1483+
bool expires_in_hardirq;
14831484
int restart;
14841485

14851486
lockdep_assert_held(&cpu_base->lock);
@@ -1514,11 +1515,11 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
15141515
*/
15151516
raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
15161517
trace_hrtimer_expire_entry(timer, now);
1517-
lockdep_hrtimer_enter(timer);
1518+
expires_in_hardirq = lockdep_hrtimer_enter(timer);
15181519

15191520
restart = fn(timer);
15201521

1521-
lockdep_hrtimer_exit(timer);
1522+
lockdep_hrtimer_exit(expires_in_hardirq);
15221523
trace_hrtimer_expire_exit(timer);
15231524
raw_spin_lock_irq(&cpu_base->lock);
15241525

0 commit comments

Comments
 (0)