Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F14DC43217 for ; Mon, 15 Nov 2021 19:52:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5528261B48 for ; Mon, 15 Nov 2021 19:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344962AbhKOTrO (ORCPT ); Mon, 15 Nov 2021 14:47:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:40732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239194AbhKOR5m (ORCPT ); Mon, 15 Nov 2021 12:57:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 982C863332; Mon, 15 Nov 2021 17:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636997689; bh=LYR2W95ebjp7DRuQ9X3HmqQlJt75WLxMhBbupiA0wIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KobbI3QdzpRta++y7+BX/BhWDIOxMvfyRMxnyATTCLQWfXQThnWUqH5h5wjD16MRi u7PgBN4okAdW9dc8yMuPbwpZtSdz6mfXJuRLjMdM47ko3isknvfV4tNMNMNnhkul20 jo4e9vfmY+kLnur5YdiTRe2cMTBGOcOG8CPUoVEU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Nick Desaulniers , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 5.10 239/575] ARM: clang: Do not rely on lr register for stacktrace Date: Mon, 15 Nov 2021 17:59:24 +0100 Message-Id: <20211115165351.996311275@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165343.579890274@linuxfoundation.org> References: <20211115165343.579890274@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit b3ea5d56f212ad81328c82454829a736197ebccc ] Currently the stacktrace on clang compiled arm kernel uses the 'lr' register to find the first frame address from pt_regs. However, that is wrong after calling another function, because the 'lr' register is used by 'bl' instruction and never be recovered. As same as gcc arm kernel, directly use the frame pointer (r11) of the pt_regs to find the first frame address. Note that this fixes kretprobe stacktrace issue only with CONFIG_UNWINDER_FRAME_POINTER=y. For the CONFIG_UNWINDER_ARM, we need another fix. Signed-off-by: Masami Hiramatsu Reviewed-by: Nick Desaulniers Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- arch/arm/kernel/stacktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c index 76ea4178a55cb..db798eac74315 100644 --- a/arch/arm/kernel/stacktrace.c +++ b/arch/arm/kernel/stacktrace.c @@ -54,8 +54,7 @@ int notrace unwind_frame(struct stackframe *frame) frame->sp = frame->fp; frame->fp = *(unsigned long *)(fp); - frame->pc = frame->lr; - frame->lr = *(unsigned long *)(fp + 4); + frame->pc = *(unsigned long *)(fp + 4); #else /* check current frame pointer is within bounds */ if (fp < low + 12 || fp > high - 4) -- 2.33.0