From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD8FFC33CB3 for ; Fri, 17 Jan 2020 17:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 908BE2467D for ; Fri, 17 Jan 2020 17:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729372AbgAQRnM (ORCPT ); Fri, 17 Jan 2020 12:43:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:40012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729022AbgAQRla (ORCPT ); Fri, 17 Jan 2020 12:41:30 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC20722522; Fri, 17 Jan 2020 17:41:29 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.93) (envelope-from ) id 1isVce-000QQC-KQ; Fri, 17 Jan 2020 12:41:28 -0500 Message-Id: <20200117174128.500939543@goodmis.org> User-Agent: quilt/0.65 Date: Fri, 17 Jan 2020 12:41:19 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-rt-users Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Julia Cartwright , Daniel Wagner , Tom Zanussi , Julien Grall Subject: [PATCH RT 08/32] hrtimer: Use READ_ONCE to access timer->base in hrimer_grab_expiry_lock() References: <20200117174111.282847363@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org 4.19.94-rt39-rc1 stable review patch. If anyone has any objections, please let me know. ------------------ From: Julien Grall [ Upstream commit 2c8fdbe7ef0ad06c1a326886c5954e117b5657d6 ] The update to timer->base is protected by the base->cpu_base->lock(). However, hrtimer_grab_expirty_lock() does not access it with the lock. So it would theorically be possible to have timer->base changed under our feet. We need to prevent the compiler to refetch timer->base so the check and the access is performed on the same base. Other access of timer->base are either done with a lock or protected with READ_ONCE(). So use READ_ONCE() in hrtimer_grab_expirty_lock(). Signed-off-by: Julien Grall Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) --- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 94d97eae0a46..d6026c170c2d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -941,7 +941,7 @@ EXPORT_SYMBOL_GPL(hrtimer_forward); void hrtimer_grab_expiry_lock(const struct hrtimer *timer) { - struct hrtimer_clock_base *base = timer->base; + struct hrtimer_clock_base *base = READ_ONCE(timer->base); if (base && base->cpu_base) { spin_lock(&base->cpu_base->softirq_expiry_lock); -- 2.24.1