Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp239612rwb; Mon, 26 Sep 2022 11:39:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Kf2bxWlq985Dl5e2u+BNEcL6XK+3n8ZrWN9TvLOAmGe55Ol1wTpP97tKjbHaoIb74ILkS X-Received: by 2002:a17:906:3a15:b0:73d:80bf:542c with SMTP id z21-20020a1709063a1500b0073d80bf542cmr19896978eje.633.1664217593774; Mon, 26 Sep 2022 11:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664217593; cv=none; d=google.com; s=arc-20160816; b=R9RckrIfvLfvzVJoma42Ls6ptGuLlvpeB3YSBb6wjf6tHnNsU28ySci72z7/uU20h+ LWESFlhYyTXNjcEyAOk3FZcxlOwOAh3qq9OeZg3B59NDVBkhGmVft17SVkvSeh4nHdAN MP7b2Dsu5KvM11i/DJgGHfjJ2Wbs6IsmByA8UXm+bTWUK8Fa3fqhpvMRyhwOdUc/iKsg WFB7eoXkVgiaMSGYC/Vb19O02hmwuaPueiQWCfWvNmnUKgJyHZmFplW2P63Lyneak3CT c7iSP3cAaSBzZiIMJMvDu1es1JTlPIH784r9k2n2niYSjB+43FZFQLSGMiTh0GWRlupk XBng== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=H8iIvZ5iK0H7Dy8aOKjI5+sKLslpwIKrPBKPzmIlVng=; b=mhE3dXf//XPczjotdbRfmvUTvUKufSl3EtoZZdnte5wyJHMb0Pm4RZj93cf1frSb+Q 8nsRu1k/GhwSC6n/V+5wVwI7Iz+V1H6PX7HlTGovi3y+tVp4dIA5TMNcxeha3uPsMEr8 UygLExPcfoSy5Ff49qyrM/cMG1g/CeiEmXBIPn2RgsBkXlwn+h2YI7dPfwC6hQW9aH4c wAwIDDn6AljCJs0Aekp5N6TTA8SdYBz3O4+zm2H3/dI5JsCl5dMenxkZBNzj7FAuzP2x glQ/uZkP/K7dwo0EiIEkQjD5d9ErG76pGhV/5+7DzZ9JQXLhRoo+i3l6gRqFBUKrzc2t 3TjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a170906724900b00783ce92d77esi541573ejk.539.2022.09.26.11.39.28; Mon, 26 Sep 2022 11:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbiIZSga (ORCPT + 99 others); Mon, 26 Sep 2022 14:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbiIZSgZ (ORCPT ); Mon, 26 Sep 2022 14:36:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553792F01E for ; Mon, 26 Sep 2022 11:36:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F484B80D42 for ; Mon, 26 Sep 2022 18:36:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E743AC433D6; Mon, 26 Sep 2022 18:36:14 +0000 (UTC) Date: Mon, 26 Sep 2022 14:37:23 -0400 From: Steven Rostedt To: Liao Chang Cc: , , , , , , Masami Hiramatsu Subject: Re: [PATCH] kprobes: Mark ftrace mcount handler functions nokprobe Message-ID: <20220926143723.73032f8c@gandalf.local.home> In-Reply-To: <20220919084533.42318-1-liaochang1@huawei.com> References: <20220919084533.42318-1-liaochang1@huawei.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Sep 2022 16:45:33 +0800 Liao Chang wrote: > Mark ftrace mcount handler functions nokprobe since probing on these > functions probably reaches mcount recursivly during kprobe breakpoint > handler for some architecture(tested for riscv, arm64), and reenter > kprobe is treated as a fatal error, causes kernel panic. This looks to me that the affected archs should be made more robust for this case than to add this to the generic code. -- Steve > > Pesudo code below demonstrate this problem: > > mcount > function_trace_call (probed) > arch_breakpoint_handler > arch_setup_singlestep [mcount] > function_trace_call (probed) > arch_breakpoint_handler > reenter_kprobe > BUG > > Signed-off-by: Liao Chang > --- > kernel/trace/trace_functions.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c > index 9f1bfbe105e8..440a678a8c7c 100644 > --- a/kernel/trace/trace_functions.c > +++ b/kernel/trace/trace_functions.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #include "trace.h" > > @@ -194,6 +195,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, > > ftrace_test_recursion_unlock(bit); > } > +NOKPROBE_SYMBOL(function_trace_call); > > #ifdef CONFIG_UNWINDER_ORC > /* > @@ -245,6 +247,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip, > atomic_dec(&data->disabled); > local_irq_restore(flags); > } > +NOKPROBE_SYMBOL(function_stack_trace_call); > > static inline bool is_repeat_check(struct trace_array *tr, > struct trace_func_repeats *last_info, > @@ -321,6 +324,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, > out: > ftrace_test_recursion_unlock(bit); > } > +NOKPROBE_SYMBOL(function_no_repeats_trace_call); > > static void > function_stack_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, > @@ -363,6 +367,7 @@ function_stack_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, > atomic_dec(&data->disabled); > local_irq_restore(flags); > } > +NOKPROBE_SYMBOL(function_stack_no_repeats_trace_call); > > static struct tracer_opt func_opts[] = { > #ifdef CONFIG_STACKTRACE