Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2943245pxj; Sun, 6 Jun 2021 20:26:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy113t8IjsUEUlY/mrMrcKPLOLmD9Qz7YoHMFfsMPHHchCWWVrBjmj3oRrmbFcH2k+25tFg X-Received: by 2002:a05:6402:685:: with SMTP id f5mr17771158edy.178.1623036408658; Sun, 06 Jun 2021 20:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623036408; cv=none; d=google.com; s=arc-20160816; b=ZpuRJrjeTNSTGZuDpwddM0czX2MuZe7Iu36c7YPxpRgD4lOrL3A1lxEFNXObcN7VoW QmMnX/PMtdAel0YoQmi9mmy1RP0td0a8uiaolxudZN1AB2H2dkl7pOgDQEMPE8I7naLg ajpovfJmsgEN/1bjX7pCOH03TEgXrO4WMl/h4UIB/OE0AoIhYpNjY0oWJug4Q2JLUUgS phf60W8nJKrYhk/XXg646ZurFzEHEZoZ/DgsiW+T4sPQ/iCZxgUPY+LQM645JLXWZ70O ndJRrpkh9xu7NKRGl2jVXS2pil/LSdiFPqtxoqiaOBGlEdIPpJ+uumUTHVDuh+RICxAH RbYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=7+92JZw4JwLjCSwZPNNMIJznJ+V0xZTku0QDAHoJ6PQ=; b=nxTDGNvXFJs3Sb8XC7BE+Hp+wJy4qRefO7kta/bYa0JUiLiRVTtj5dnXIfyC8Ci2GQ p/Tp2VMtcfffzyH3mQRzdppgqjYXr94O6vcfNAVlLW+1tkvL6a6JnFZ+2qWSJsBLY5Jo jK5DSTBRNpMYeAk8fJ/bXoK0Tq4Diqeb1F67YpGpggF4yUg+fFiP1EBD59hHjT9D+7PO fWvr5Zy7FodSZ23hwZUrddtL6e2/BhhaFEcr635vaamaD7cK/zCfzMmRBaGObuJwVRss X8ksf3VBDiOpsGX8waoz8u3SPTjetDKTrXr8S1lHTenEN0z6lBaHtdSIsXMBdI7KefxT V7rA== ARC-Authentication-Results: i=1; mx.google.com; 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si3365842ejh.535.2021.06.06.20.26.26; Sun, 06 Jun 2021 20:26:48 -0700 (PDT) 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; 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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbhFGD0b (ORCPT + 99 others); Sun, 6 Jun 2021 23:26:31 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:60184 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230172AbhFGD0b (ORCPT ); Sun, 6 Jun 2021 23:26:31 -0400 X-UUID: 4104ab5d812e4f5cbe188db290a0ae51-20210607 X-UUID: 4104ab5d812e4f5cbe188db290a0ae51-20210607 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1696112267; Mon, 07 Jun 2021 11:24:38 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 11:24:36 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Jun 2021 11:24:36 +0800 From: Mark-PK Tsai To: Steven Rostedt CC: Ingo Molnar , Catalin Marinas , Will Deacon , Matthias Brugger , , , , , Subject: [PATCH] arm64: ftrace: don't dereference a probably invalid address Date: Mon, 7 Jun 2021 11:23:30 +0800 Message-ID: <20210607032329.28671-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). 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. 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; } /* -- 2.18.0