From patchwork Mon Feb 10 12:29:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 231692 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=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 D892DC3F68F for ; Mon, 10 Feb 2020 13:25:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2A0E2467D for ; Mon, 10 Feb 2020 13:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581341158; bh=Jq4Jre2q6+Goe1YtcWIF0yCjvk5dbcstp82dam4pzgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=F2CHU74v53Ansm+amrNMTZ2VhFp31nCTdaaLmkWrWyaW9zlXX09wm4BHeYN758LMX SFuJ7wms311A1n/wTiYRM5MbuPemSmNQq5G9sGrXUFaimqfnWIrPYIjVju3zeYL1Bj o86OGctkxQ4Ob6lLfVxVudkzSlm0TLYJdvc9vXY4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgBJMgu (ORCPT ); Mon, 10 Feb 2020 07:36:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:56700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbgBJMgt (ORCPT ); Mon, 10 Feb 2020 07:36:49 -0500 Received: from localhost (unknown [209.37.97.194]) (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 C51E7208C4; Mon, 10 Feb 2020 12:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338208; bh=Jq4Jre2q6+Goe1YtcWIF0yCjvk5dbcstp82dam4pzgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSVXHEWg3SOKbuAf/RDQJQLQidBZ9Vq3U0CRaN1S06ZZp8NR2F/r35vmQii3wHnaw gwMqxoyk/3s0ZjRtyaFH3/tJx7qlxsWWnISvs2hYma2bqicUxY2oJPVEIsK7Z7Ju5L yuJjrWVEq9xW6SEsKaMNX2qXaWfUo+imV1CIifAY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+08f3e9d26e5541e1ecf2@syzkaller.appspotmail.com, Marco Elver , "Paul E. McKenney" Subject: [PATCH 5.4 030/309] srcu: Apply *_ONCE() to ->srcu_last_gp_end Date: Mon, 10 Feb 2020 04:29:46 -0800 Message-Id: <20200210122408.925381039@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paul E. McKenney commit 844a378de3372c923909681706d62336d702531e upstream. The ->srcu_last_gp_end field is accessed from any CPU at any time by synchronize_srcu(), so non-initialization references need to use READ_ONCE() and WRITE_ONCE(). This commit therefore makes that change. Reported-by: syzbot+08f3e9d26e5541e1ecf2@syzkaller.appspotmail.com Acked-by: Marco Elver Signed-off-by: Paul E. McKenney Signed-off-by: Greg Kroah-Hartman --- kernel/rcu/srcutree.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -530,7 +530,7 @@ static void srcu_gp_end(struct srcu_stru idx = rcu_seq_state(ssp->srcu_gp_seq); WARN_ON_ONCE(idx != SRCU_STATE_SCAN2); cbdelay = srcu_get_delay(ssp); - ssp->srcu_last_gp_end = ktime_get_mono_fast_ns(); + WRITE_ONCE(ssp->srcu_last_gp_end, ktime_get_mono_fast_ns()); rcu_seq_end(&ssp->srcu_gp_seq); gpseq = rcu_seq_current(&ssp->srcu_gp_seq); if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq)) @@ -762,6 +762,7 @@ static bool srcu_might_be_idle(struct sr unsigned long flags; struct srcu_data *sdp; unsigned long t; + unsigned long tlast; /* If the local srcu_data structure has callbacks, not idle. */ local_irq_save(flags); @@ -780,9 +781,9 @@ static bool srcu_might_be_idle(struct sr /* First, see if enough time has passed since the last GP. */ t = ktime_get_mono_fast_ns(); + tlast = READ_ONCE(ssp->srcu_last_gp_end); if (exp_holdoff == 0 || - time_in_range_open(t, ssp->srcu_last_gp_end, - ssp->srcu_last_gp_end + exp_holdoff)) + time_in_range_open(t, tlast, tlast + exp_holdoff)) return false; /* Too soon after last GP. */ /* Next, check for probable idleness. */