Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3268109pxb; Mon, 9 Nov 2020 07:01:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6x/n2+UoeunceTPPyELije9PaFl/tDWnP9ZvHiohzXnmMBIvgKpXAmJpm2oSCLt6YRyKq X-Received: by 2002:a7b:ce0c:: with SMTP id m12mr14377485wmc.114.1604934064430; Mon, 09 Nov 2020 07:01:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604934064; cv=none; d=google.com; s=arc-20160816; b=Hnxg+04qTE6os389GnrRpgD1gwLzUmnyhy3AEaPTAevVCFDuEU+2a1SqLQZadij8QF BjzUHgMcISENltmEcNihkyAuvGZD3hbHdN3vMWaWiuLc9Kq4LpDv7LtjCGfJ3AHNlMy7 4Yq87YQj9Ywgs6olmOMHuUmU0UEzb1HzgUDURzp4xu7zQMDqNYXND32LJFRLvdImuOx6 ySy/+o7Bo91n0WLRjrZw+vUo/CaqbpIGfsYyCsPTlQfEpJDfL5PUQ5ffKkgurjulqbuX LvS+HWAamwy3IshqMwemruYFbzDagaahojYbaZZcMywFv4tKmRHLuVd6S7edTCiNhC5E ACNg== 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=cft7dwse39KBKsUuyetoxd5+I/zlZyXrp+v+oZrqlYI=; b=YHinxLW4lj11468bSV4U/dTxw4xI2PKPgkqzdEfB19kN9IgOJBOoFzZ151tTKRbwGT 6fB74duZvBhlRu/pOrLQVwnNSIAlVHrHo5sf+LrA6hlx/+HVH6wcejt80Ywf+P0slAAC o9ZxoRYYF860FFUy3sPDKOZkrvcrqAtdG0qxDGMJvJBGl8z4ii5ceqP3QPftam7eww9b aAT9++PhXqWsyalENuQp27GDqH+pe/jnVWYwWLBbLDmiRqCXOd0tKMomELuZinBH8hpI 3d+7Wy7zAKGhvLMLJ1lsuS4xt5DouGLYkNJGV9/7Pm1aNn3mBDGPv5tTFkU2/JFz159S mUlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g++hJb8R; 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 r25si7025585edy.166.2020.11.09.07.00.40; Mon, 09 Nov 2020 07:01:04 -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=g++hJb8R; 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 S1729661AbgKINhK (ORCPT + 99 others); Mon, 9 Nov 2020 08:37:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:57592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729884AbgKINEn (ORCPT ); Mon, 9 Nov 2020 08:04:43 -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 F00F0216C4; Mon, 9 Nov 2020 13:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927067; bh=27MjlQ3L+4iwZee+WVZ31eD48P6EtzL01HRab65Zr/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g++hJb8Rgt/zcLxYsXtFMFhgVTXqNr1M453n3W+vwGPdoh8Lsjh2UumR5VOD2HsPs ScrjguDPYnp1bBZxHGMBw/XcP7n7LiVlBsEdU1TfXjzqiiEICmijVOGe6xxrHLxp9w IVev6aTxZAxhiZAOSp66bZZ0ySeB8slBg3ByKNgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 4.9 099/117] ftrace: Fix recursion check for NMI test Date: Mon, 9 Nov 2020 13:55:25 +0100 Message-Id: <20201109125030.400396106@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 @@ -542,7 +542,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) @@ -552,6 +552,7 @@ static __always_inline void trace_clear_ if (!bit) return; + bit--; bit = 1 << bit; val &= ~bit;