From patchwork Mon Nov 9 12:55:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 322615 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 BBF79C388F7 for ; Mon, 9 Nov 2020 13:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B2F5206B2 for ; Mon, 9 Nov 2020 13:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604929043; bh=27MjlQ3L+4iwZee+WVZ31eD48P6EtzL01HRab65Zr/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ePH8VF9QXH6tqQfisYtLwbx8D7MHwAzeVGVSv8HcF8YqQLduOJlvB+8t8WXXkiojA g15zUaX103sx5dbNn8drZCxC75PQ6Wy3G9DEhF5JRpr0+4blbuqKeBleEHSe+PXiDF bQbYs/szT3U8KnkibEWUs5EVhpcdx6CzHk6U+4gA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730974AbgKINhJ (ORCPT ); Mon, 9 Nov 2020 08:37:09 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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;