From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham 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 A5C50C47082 for ; Mon, 7 Jun 2021 13:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DD1E61159 for ; Mon, 7 Jun 2021 13:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbhFGN5N (ORCPT ); Mon, 7 Jun 2021 09:57:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:59184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbhFGN5M (ORCPT ); Mon, 7 Jun 2021 09:57:12 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 62BFB610FB; Mon, 7 Jun 2021 13:55:20 +0000 (UTC) Date: Mon, 7 Jun 2021 09:55:18 -0400 From: Steven Rostedt To: Mark-PK Tsai Cc: Ingo Molnar , Catalin Marinas , Will Deacon , Matthias Brugger , , , , Subject: Re: [PATCH] arm64: ftrace: don't dereference a probably invalid address Message-ID: <20210607095518.12694437@oasis.local.home> In-Reply-To: <20210607032329.28671-1-mark-pk.tsai@mediatek.com> References: <20210607032329.28671-1-mark-pk.tsai@mediatek.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Jun 2021 11:23:30 +0800 Mark-PK Tsai wrote: > Address in __mcount_loc may be invalid if somthing goes wrong. > On our arm64 platform, the bug in recordmcount make kernel > crash in ftrace_init(). How did it crash? The link below doesn't show any crash. > > https://lore.kernel.org/lkml/20210607023839.26387-1-mark-pk.tsai@mediatek.com/ > > Return -EFAULT if we are dealing with out-of-range condition > to prevent dereference the invalid address in ftrace_bug(), > then the kernel can disable ftrace safely for problematic > __mcount_loc. !mod is not an out-of-range condition. It just happened that the other bug caused this strange side-effect. A !mod does not mean a fault happened. Just because it may have been caused by a fault in your use case does not mean that it's a fault in all use cases. That's like saying that your dog is a poodle, so all dogs are poodles. A return of -EINVAL should not cause a crash. If it does, then that needs to be fixed. -- Steve > > Signed-off-by: Mark-PK Tsai > --- > arch/arm64/kernel/ftrace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c > index b5d3ddaf69d9..98bec8445a58 100644 > --- a/arch/arm64/kernel/ftrace.c > +++ b/arch/arm64/kernel/ftrace.c > @@ -201,7 +201,7 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, > preempt_enable(); > > if (WARN_ON(!mod)) > - return -EINVAL; > + return -EFAULT; > } > > /*