Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3197190pxb; Mon, 9 Nov 2020 05:22:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJypaqdXJVo9B1iMFw+p8OsxLxp4F1+byr71077FjsCgdBKaFodtiFxjPIp34D75r4JYbPPR X-Received: by 2002:a50:d8ce:: with SMTP id y14mr15767027edj.90.1604928149234; Mon, 09 Nov 2020 05:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928149; cv=none; d=google.com; s=arc-20160816; b=mKmRzlHqXP9zw67X5u+FQnae9p9ME3ru5N56VlV1HIuxR1R+mcLIuvC1HFV21xIekV Exy6hWfwumcFLvcfuwrxL/4LoQIbp8isTtAfg1JXEp+Kg3ae3JzISMHsL9UrXAb/CU8M 82YAZkvJO0VAHWd9xLdMRAX8kgDAVPWt+Ht9CwuqhIdD5q1MGR8n2g6egaz5gcQenJW5 /zIGrJlVuSafqitasCQBzfx90nsBuwY/RMuqSev2ntPpcyp92AAIcPLv7L0zNtJSNDWA zx4QodFdcjj/lkGna103mEBqxbzENe948ZM8sONexZ2VO8acGKzau1osG/9COzMCBWvo 35RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SnqqWxmg2DCIND1fJJFKB/j1H1Y2xDfh2khXCpnOKvA=; b=0BM/W3bp22MvzzkJ2zBnzlRPxi+3YsA8z46xHsajvoGNUwEDiGEQ9CDMD6dkD/batM sEmTNLIs7HyqDbdc7FB5TjR4pOJr1LGUm3ws11I/K1WqwF8NG442Bp+Cfx27Gd9wJv0a zy/F36PJqz99GtHEJVHLquyRB2PXgGs2pD2uZhA3pJdobUuhNDtPSvbIXMX07gUFCMpd dUzUfZ0gZNTo/IAsBit0EY95mTdCwGy5dYSz7btXKGqeVXPJbjH505C3Wfnp8bJ8mCek /lvc5B9ZKlkvTzJUVjjB1qX8wCQIQaKsQPl9Sfr1ryH3iBkYx12tjEXzrQX1mnVWm3I8 uP+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="L/tIGRza"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx23si7051867ejb.257.2020.11.09.05.22.04; Mon, 09 Nov 2020 05:22:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="L/tIGRza"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733308AbgKINUv (ORCPT + 99 others); Mon, 9 Nov 2020 08:20:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:48408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387976AbgKINUq (ORCPT ); Mon, 9 Nov 2020 08:20:46 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 AC5B2206D8; Mon, 9 Nov 2020 13:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604928045; bh=BwQ6VG+gjhfz0EqD6NV1hgsz137g69CXNnH/vrOTCFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L/tIGRzaKjsubk45Vl3at9pWXn7x1aSMNx7xN78sAwGjwExFK8R9sGMtIxOYD0MFx 0B/A24L0/yg/wZOFbmygPGhIFmD3TZng47qU8LglsBOGfJEzT/vjfVkL6S+Qa1iIaQ fXjdGXf+zSuUUUMS8bhEc0EHbNXGu7mIVLvAWVOM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Thomas Gleixner Subject: [PATCH 5.9 109/133] entry: Fix the incorrect ordering of lockdep and RCU check Date: Mon, 9 Nov 2020 13:56:11 +0100 Message-Id: <20201109125035.932625125@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 9d820f68b2bdba5b2e7bf135123c3f57c5051d05 upstream. When an exception/interrupt hits kernel space and the kernel is not currently in the idle task then RCU must be watching. irqentry_enter() validates this via rcu_irq_enter_check_tick(), which in turn invokes lockdep when taking a lock. But at that point lockdep does not yet know about the fact that interrupts have been disabled by the CPU, which triggers a lockdep splat complaining about inconsistent state. Invoking trace_hardirqs_off() before rcu_irq_enter_check_tick() defeats the point of rcu_irq_enter_check_tick() because trace_hardirqs_off() uses RCU. So use the same sequence as for the idle case and tell lockdep about the irq state change first, invoke the RCU check and then do the lockdep and tracer update. Fixes: a5497bab5f72 ("entry: Provide generic interrupt entry/exit code") Reported-by: Mark Rutland Signed-off-by: Thomas Gleixner Tested-by: Mark Rutland Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/87y2jhl19s.fsf@nanos.tec.linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/entry/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -338,10 +338,10 @@ noinstr irqentry_state_t irqentry_enter( * already contains a warning when RCU is not watching, so no point * in having another one here. */ + lockdep_hardirqs_off(CALLER_ADDR0); instrumentation_begin(); rcu_irq_enter_check_tick(); - /* Use the combo lockdep/tracing function */ - trace_hardirqs_off(); + trace_hardirqs_off_finish(); instrumentation_end(); return ret;