Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753678AbdFSShd (ORCPT + 2 others); Mon, 19 Jun 2017 14:37:33 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:52505 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753623AbdFSSh0 (ORCPT ); Mon, 19 Jun 2017 14:37:26 -0400 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Thomas Gleixner , Mark Rutland , Anna-Maria Gleixner , Richard Cochran , Sebastian Andrzej Siewior , Daniel Lezcano , Peter Zijlstra , Sebastian Frias , Thibaud Cornic , Robin Murphy , Jiri Slaby , Willy Tarreau Subject: [PATCH 3.10 083/268] tick/broadcast: Prevent NULL pointer dereference Date: Mon, 19 Jun 2017 20:29:42 +0200 Message-Id: <1497897167-14556-84-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1497897167-14556-1-git-send-email-w@1wt.eu> References: <1497897167-14556-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Thomas Gleixner commit c1a9eeb938b5433947e5ea22f89baff3182e7075 upstream. When a disfunctional timer, e.g. dummy timer, is installed, the tick core tries to setup the broadcast timer. If no broadcast device is installed, the kernel crashes with a NULL pointer dereference in tick_broadcast_setup_oneshot() because the function has no sanity check. Reported-by: Mason Signed-off-by: Thomas Gleixner Cc: Mark Rutland Cc: Anna-Maria Gleixner Cc: Richard Cochran Cc: Sebastian Andrzej Siewior Cc: Daniel Lezcano Cc: Peter Zijlstra , Cc: Sebastian Frias Cc: Thibaud Cornic Cc: Robin Murphy Link: http://lkml.kernel.org/r/1147ef90-7877-e4d2-bb2b-5c4fa8d3144b@free.fr Signed-off-by: Jiri Slaby Signed-off-by: Willy Tarreau --- kernel/time/tick-broadcast.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 19ee339..6f27814 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -775,6 +775,9 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc) { int cpu = smp_processor_id(); + if (!bc) + return; + /* Set it up only once ! */ if (bc->event_handler != tick_handle_oneshot_broadcast) { int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; -- 2.8.0.rc2.1.gbe9624a