From patchwork Mon Feb 10 12:29:47 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: 231691 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=ham 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 B1233C352A3 for ; Mon, 10 Feb 2020 13:26:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 819D92082F for ; Mon, 10 Feb 2020 13:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581341165; bh=J62eTd3bqr5j/L4W1LyHoRheWIg3gYLbwbNKiE5D1Fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=q8JeuvTAUxSJNu5LCvEgxjCub89EAysMAbZVX/mOF+lD87GOt5xRzOoNK6flgreRN EOEjRDVW36/YfHTTw7w7W3H0GQwrdZAdkcRiLERAZOlJ11ck3Xi9/umE9g0+96PZq0 8woFrCop9QKn8KI3bxaknQ9sCBFg8bJebhsWyCYQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728536AbgBJN0E (ORCPT ); Mon, 10 Feb 2020 08:26:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:56722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728529AbgBJMgt (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 4AB1F2465D; Mon, 10 Feb 2020 12:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338209; bh=J62eTd3bqr5j/L4W1LyHoRheWIg3gYLbwbNKiE5D1Fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIUqMAbwSdmR/IcXaP/zsm93QaMojgwBZ/cxztVJaByhsNsHyFbSCLz3jdHfYWPMy afZR4143BkXv/2fCEepV73njeoq6rFJgMmfyg44/TgQF7g8VXiTTpMo7Sd60tY6477 owvct4xQFS77J+qvLabgcY3G7DxeoQk5+tx/yAyc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+99f4ddade3c22ab0cf23@syzkaller.appspotmail.com, "Paul E. McKenney" , Marco Elver Subject: [PATCH 5.4 031/309] rcu: Use READ_ONCE() for ->expmask in rcu_read_unlock_special() Date: Mon, 10 Feb 2020 04:29:47 -0800 Message-Id: <20200210122409.041496530@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 c51f83c315c392d9776c33eb16a2fe1349d65c7f upstream. The rcu_node structure's ->expmask field is updated only when holding the ->lock, but is also accessed locklessly. This means that all ->expmask updates must use WRITE_ONCE() and all reads carried out without holding ->lock must use READ_ONCE(). This commit therefore changes the lockless ->expmask read in rcu_read_unlock_special() to use READ_ONCE(). Reported-by: syzbot+99f4ddade3c22ab0cf23@syzkaller.appspotmail.com Signed-off-by: Paul E. McKenney Acked-by: Marco Elver Signed-off-by: Greg Kroah-Hartman --- kernel/rcu/tree_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -612,7 +612,7 @@ static void rcu_read_unlock_special(stru t->rcu_read_unlock_special.b.exp_hint = false; exp = (t->rcu_blocked_node && t->rcu_blocked_node->exp_tasks) || - (rdp->grpmask & rnp->expmask) || + (rdp->grpmask & READ_ONCE(rnp->expmask)) || tick_nohz_full_cpu(rdp->cpu); // Need to defer quiescent state until everything is enabled. if (irqs_were_disabled && use_softirq &&