From patchwork Mon Mar 15 16:57:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhavan T. Venkataraman" X-Patchwork-Id: 12140101 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 66408C433DB for ; Mon, 15 Mar 2021 17:01:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 0A09664DDE for ; Mon, 15 Mar 2021 17:01:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A09664DDE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com 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=desiato.20200630; 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:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BgETyyczWkEQ2R4SLasPoR17aBZYjMB4DtEM3Xdpyk0=; b=M75YwhxfZ4QlYHpgSFYqmZ7uI S0L/xbzOSU+C7CcBY9ZQ8geAiCEGIChIMIsGxLzWrK2ymbfEliThfOlsdED5U7/mdlvEOcF368idy G4S3zoS5DtkufMClzJihLjAODe0xkdPEgy265M4VGV5O+yb5o2gVL4UhNV2l1QEjnKu8QZLQCYJOu nGbmQJ/6fNRDLSjcK7AakhTvzwj7z57Qi6KZ/RenUx1c0K0qZWm9m4fNiB+j1cRpu0ZawCndOXHV2 QrLU0PR+h46XmsCXfc7SAfZjSDbzyJdj/azPUzzF10x11SPHz+uOy//gefE6bgxmnk1OIfGHIb9DN bPLx5EzDA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLqYu-00GQ4B-Qu; Mon, 15 Mar 2021 16:59:31 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLqXq-00GPor-Ei for linux-arm-kernel@lists.infradead.org; Mon, 15 Mar 2021 16:58:21 +0000 Received: from x64host.home (unknown [47.187.194.202]) by linux.microsoft.com (Postfix) with ESMTPSA id 8650420B26FE; Mon, 15 Mar 2021 09:58:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8650420B26FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1615827496; bh=jheyVZ/lUkxf4Ht1TtTUL0sobQn62YR0CVwzSLRcRdA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QJ42h8pS1O+0cURPnA4fdCqupwkpfS259xG/1wglI00VOExTU1uQoa03R3XOzBYrb lkMnRDAYrogw1NMDoZ7NnPHshtec1eFkIan34A5ppztxARo+x+Rg7Y2tjMJDA+p1am cYsgch6qRqbr/azncTfOJfhMUWYyvtO0UgZt21SI= From: madvenka@linux.microsoft.com To: broonie@kernel.org, mark.rutland@arm.com, jpoimboe@redhat.com, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [RFC PATCH v2 6/8] arm64: Check the return PC of every stack frame Date: Mon, 15 Mar 2021 11:57:58 -0500 Message-Id: <20210315165800.5948-7-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210315165800.5948-1-madvenka@linux.microsoft.com> References: <5997dfe8d261a3a543667b83c902883c1e4bd270> <20210315165800.5948-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210315_165820_457747_90934DE7 X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Madhavan T. Venkataraman" If a function encountered in a stack trace is not a valid kernel text address, the stack trace is considered unreliable. Mark the stack trace as not reliable. Signed-off-by: Madhavan T. Venkataraman --- arch/arm64/kernel/stacktrace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 594806a0c225..358aae3906d7 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -101,6 +101,16 @@ static void check_if_reliable(unsigned long fp, struct stackframe *frame, } } #endif + + /* + * A NULL or invalid return address probably means there's some + * generated code which __kernel_text_address() doesn't know about. + * Mark the stack trace as not reliable. + */ + if (!__kernel_text_address(frame->pc)) { + frame->reliable = false; + return; + } } /*