Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp986004imu; Fri, 11 Jan 2019 12:44:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4NNQB6Xwr0trmkx7gtWShPrly0vLUJWJItFHPjNg8g2dLQvE7nkhB6ZSZLQtodFEufzrYw X-Received: by 2002:a62:4886:: with SMTP id q6mr16479672pfi.182.1547239497636; Fri, 11 Jan 2019 12:44:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547239497; cv=none; d=google.com; s=arc-20160816; b=GFHKJQzKf0Nlgy+E/h0/9kjfdxDYvkGEfMqUg53G5Z/MRtILAZOD57JyldjsEIFNEl 3SBN50z7/KZvyVot8LjLrEAMYRhVHZveQ3rDJ4rAwAbSQSro9os+oSdHP4H0Sl0J4v/Q VZGjU5OgEP66CWh0IWBMpUYrbTEjqVmyHvOMVShEAIxT7a6E3ayaXMXNf6UueRysNM3C pizJkzKKe2ELd//QLtjJA2bDG/1wMETUGm+ycCHQU0M7Qo3ZMjQXOaxAD1rC5H8DLVlP F+Ccc1ondDFTCGFiQxIhnYxesA4LMuzPjIBhiVBtyjoDi1zOb1xb/7oemcLoX0bECx++ dWGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U4+Ecy+rgk5+lBnTmlFvAIP1A0CP3bBxujgLQPmvY70=; b=XjHxYrJ+uoEu8U5unojyglH5YYJLdbuwL7pccy3/n8fEaggKb4ksRJI+bMSAw+RvGI bjNTVYVexC/1atmnVQNefjSL2Ue+9LUXucHBDb/JTa01ZYB5idBr+9Ssk8YWD4byHQSZ q6wLY9KEdFleJeD93+iY/DkRzZVMpWubPb01BD6HsBnKpCl8yRNV2jS47KFVaNWNTcuM kGBbzHIQT8nmomp5fX05N2QSm9asElL6iM/GXzsM+NVXBKuhF7xi3dQtO487PUvo8qeK YzjoHfyYEcsuI/A+WcGThN+f4cEy7NSElWsl8BTXc3rAtl8SxQB4UaYq8YgaRMnE93Yv JB4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfxPcc15; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si9676048pli.432.2019.01.11.12.44.42; Fri, 11 Jan 2019 12:44:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfxPcc15; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404142AbfAKOmX (ORCPT + 99 others); Fri, 11 Jan 2019 09:42:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:35112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391375AbfAKOmU (ORCPT ); Fri, 11 Jan 2019 09:42:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 C604F21848; Fri, 11 Jan 2019 14:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217740; bh=Ex/KFTgNrf1hHYJvb848wwO+/XrA7qOS6iLUqLPThp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfxPcc1589wPMi8youkoykDjegGOXT4Bwr+oD9QHkFNN4jw89xufstl0lIY7gpPxp 6HirejLbD9JmRM7+g7yOlvDRbFA153i2Qt9+9d/SvjBKLOp0/yevbHw54QS+eNRIPn aTPPG4pfPbaXV52emeWX37bLY80S7fsyC+c9eeYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Sebastian Kuzminsky , Dennis Krein , "Paul E. McKenney" Subject: [PATCH 4.20 23/65] srcu: Lock srcu_data structure in srcu_gp_start() Date: Fri, 11 Jan 2019 15:15:09 +0100 Message-Id: <20190111131059.607320719@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dennis Krein commit eb4c2382272ae7ae5d81fdfa5b7a6c86146eaaa4 upstream. The srcu_gp_start() function is called with the srcu_struct structure's ->lock held, but not with the srcu_data structure's ->lock. This is problematic because this function accesses and updates the srcu_data structure's ->srcu_cblist, which is protected by that lock. Failing to hold this lock can result in corruption of the SRCU callback lists, which in turn can result in arbitrarily bad results. This commit therefore makes srcu_gp_start() acquire the srcu_data structure's ->lock across the calls to rcu_segcblist_advance() and rcu_segcblist_accelerate(), thus preventing this corruption. Reported-by: Bart Van Assche Reported-by: Christoph Hellwig Reported-by: Sebastian Kuzminsky Signed-off-by: Dennis Krein Signed-off-by: Paul E. McKenney Tested-by: Dennis Krein Cc: # 4.16.x Signed-off-by: Greg Kroah-Hartman --- kernel/rcu/srcutree.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -451,10 +451,12 @@ static void srcu_gp_start(struct srcu_st lockdep_assert_held(&ACCESS_PRIVATE(sp, lock)); WARN_ON_ONCE(ULONG_CMP_GE(sp->srcu_gp_seq, sp->srcu_gp_seq_needed)); + spin_lock_rcu_node(sdp); /* Interrupts already disabled. */ rcu_segcblist_advance(&sdp->srcu_cblist, rcu_seq_current(&sp->srcu_gp_seq)); (void)rcu_segcblist_accelerate(&sdp->srcu_cblist, rcu_seq_snap(&sp->srcu_gp_seq)); + spin_unlock_rcu_node(sdp); /* Interrupts remain disabled. */ smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */ rcu_seq_start(&sp->srcu_gp_seq); state = rcu_seq_state(READ_ONCE(sp->srcu_gp_seq));