Commit 40ecfb28 authored by Phil Chang's avatar Phil Chang Committed by Xiongfeng Wang
Browse files

hrtimer: Prevent queuing of hrtimer without a function callback

stable inclusion
from stable-v4.19.321
commit ccef3adcb84816a30b8e535c8c4fcb167904e7b1
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAYQRI
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ccef3adcb84816a30b8e535c8c4fcb167904e7b1



--------------------------------

[ Upstream commit 5a830bbce3af16833fe0092dec47b6dd30279825 ]

The hrtimer function callback must not be NULL. It has to be specified by
the call side but it is not validated by the hrtimer code. When a hrtimer
is queued without a function callback, the kernel crashes with a null
pointer dereference when trying to execute the callback in __run_hrtimer().

Introduce a validation before queuing the hrtimer in
hrtimer_start_range_ns().

[anna-maria: Rephrase commit message]

Signed-off-by: default avatarPhil Chang <phil.chang@mediatek.com>
Signed-off-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
parent da4089b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1171,6 +1171,8 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
	struct hrtimer_clock_base *base;
	unsigned long flags;

	if (WARN_ON_ONCE(!timer->function))
		return;
	/*
	 * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft
	 * match.