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=-10.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE,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 81E6EC47082 for ; Mon, 7 Jun 2021 14:54:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3448261108 for ; Mon, 7 Jun 2021 14:54:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3448261108 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f7xvBxCq/EiaJ90tS/S8YGCiaoZ9G9+fj9LaRq4mYHc=; b=X5cZnFcoQpYacy /8dcHd4daRtFioeqpnvNLc1GrslvGvmwEe/2Mmz0VlvUxcN5naVE0YNuEFhgF6Duc8OhhzGop45by xxNDIY6EYDseMAvzq0XUH3tBwdTTsMfONltj7Ou6GznlgK/HSU1XYlUBystnEGU1V025q6Rs6R41w RRQpaJWaiaTX1S90/nzdEdevNFiUcH7503oBQJzeVYXkqbl+fkkwDJzQbAZXJuM7F+8PyMEN08guS 8Klyjyimgf97f0Fg7hD1/Ubox02wEhU6Z1nmjg+E5UHa3cghd8mnjzkAjPMGHg+sqWVGi7HKpFVf7 V6VDndl4XhWq9jsPnuqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqGc3-0047HE-Vx; Mon, 07 Jun 2021 14:52:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqGc0-0047Gp-EF; Mon, 07 Jun 2021 14:52:21 +0000 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 F368F60FE5; Mon, 7 Jun 2021 14:52:18 +0000 (UTC) Date: Mon, 7 Jun 2021 10:52:17 -0400 From: Steven Rostedt To: Mark-PK Tsai Cc: , , , , , , , Subject: Re: [PATCH] arm64: ftrace: don't dereference a probably invalid address Message-ID: <20210607105217.772214e5@oasis.local.home> In-Reply-To: <20210607141522.3281-1-mark-pk.tsai@mediatek.com> References: <20210607095518.12694437@oasis.local.home> <20210607141522.3281-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_075220_529179_FCC99E4B X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 7 Jun 2021 22:15:22 +0800 Mark-PK Tsai wrote: > And the crash is becuase kernel trying to read *rec->ip in print_ip_ins() if > ftrace_bug() get error code -EINVAL. Right, so the actual fix should be something like this: [ not tested, nor even compiled ] -- Steve diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 2e8a3fde7104..72ef4dccbcc4 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1967,12 +1967,18 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, static void print_ip_ins(const char *fmt, const unsigned char *p) { + char ins[MCOUNT_INSN_SIZE]; int i; + if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) { + printk(KERN_CONT "%s[FAULT](%px)", fmt, p); + return; + } + printk(KERN_CONT "%s", fmt); for (i = 0; i < MCOUNT_INSN_SIZE; i++) - printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]); + printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]); } enum ftrace_bug_type ftrace_bug_type; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel