Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3203433pxb; Mon, 9 Nov 2020 05:31:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXHUDVAaiYbNT/QzjdQMjkZ1tqj0g3/6BKWfazFST0KdVCKXnzNQ7yGc7RGELnkpSD+NdE X-Received: by 2002:a17:906:b255:: with SMTP id ce21mr15786584ejb.137.1604928687039; Mon, 09 Nov 2020 05:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928687; cv=none; d=google.com; s=arc-20160816; b=Vz4hBAPWCd2aqKRhs4rUrRFPzy2PR84+m93pfAsp8KXzCY0sIc8ryZZHdJzpxlFewA NP5xLt9W1LS4Fg9JHCJj0ZaHVEFcJUytQ3VVIycDny/fLD2XmvuLwK1OgffJXxGMckAk jYWdCefHn3SIV45dcVa6SxlswRlT2rV/My5TROvi4xgjpIhJGx7HmIbQX2mUdK9rc2cQ zqHOnustK3sbeQtp6fWpKxCLctl3BeP5D7Q4QnpTgbVeuLX1Q3DtakZ3KdPSEo5CqB0H NdJJU/HaEF2i98rmmM2cSo1kQjjUKjQCQvPLdmBjiiZv08yjZoPVb0W4Xsq79OXV9NpM doBA== 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=syrTj3YA3WZd3D5tyAtRzJc14uyi7we4c+bxxZPGF/o=; b=XOnPk/I1sDb9Sx0/BipvfbEXhmVHfzw90kgQwfZErj2Ziev5+ZJvYwbzdZYElfW3U0 1kvVERKsxx4OrgnK0z1VkaFAyYKKy2oFkJPNRlaLDf0LGbPVUZztEJiPp99qjK9JbpSO BZAh2rY49AXIHywUiYhu9jB9M44w3prorTgKfu5qt4TDFg4kpNlxCUi6eCZiQf7wQngM WCy3Lbndw/hqtnmSbBfAWHuMp2y9XpmfkXpv6Iub1ak/kilRaNCITqEteDis0mgvpBst 9Gge0/SDlq4ZE6JGdILGQzA0gxYYzzLwDIRlTnDaYbIQDUtAj/CJobhMMumljj15eRD9 Q3KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MfYuJOah; 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 gn35si1001288ejc.628.2020.11.09.05.31.03; Mon, 09 Nov 2020 05:31:27 -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=MfYuJOah; 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 S1731581AbgKINOc (ORCPT + 99 others); Mon, 9 Nov 2020 08:14:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:40806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733149AbgKINO2 (ORCPT ); Mon, 9 Nov 2020 08:14:28 -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 BC71220789; Mon, 9 Nov 2020 13:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927668; bh=VaIpHISW1bHeg0YK+bGy4dB54g61d2RgvK3sQTLnD6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MfYuJOahE1fbIShIubfDzwK6POVkcxBipckNONQXzhmqdRDfwA+vhjbnW4IGT4Cwp iZhACYpyyuY2bET0VoAH6h8w50BezpIMnj+B8HbQykDNYiu7PJ32KSCjCs0SoxHn7a bAb+8Au5uuZd/nCELhX9yaVfE89gD35mM8LWp8zo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 5.4 36/85] ftrace: Fix recursion check for NMI test Date: Mon, 9 Nov 2020 13:55:33 +0100 Message-Id: <20201109125024.330189877@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125022.614792961@linuxfoundation.org> References: <20201109125022.614792961@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: Steven Rostedt (VMware) commit ee11b93f95eabdf8198edd4668bf9102e7248270 upstream. The code that checks recursion will work to only do the recursion check once if there's nested checks. The top one will do the check, the other nested checks will see recursion was already checked and return zero for its "bit". On the return side, nothing will be done if the "bit" is zero. The problem is that zero is returned for the "good" bit when in NMI context. This will set the bit for NMIs making it look like *all* NMI tracing is recursing, and prevent tracing of anything in NMI context! The simple fix is to return "bit + 1" and subtract that bit on the end to get the real bit. Cc: stable@vger.kernel.org Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks") Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -653,7 +653,7 @@ static __always_inline int trace_test_an current->trace_recursion = val; barrier(); - return bit; + return bit + 1; } static __always_inline void trace_clear_recursion(int bit) @@ -663,6 +663,7 @@ static __always_inline void trace_clear_ if (!bit) return; + bit--; bit = 1 << bit; val &= ~bit;