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.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 5559DC48BE6 for ; Wed, 16 Jun 2021 11:12:17 +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 13AB460C41 for ; Wed, 16 Jun 2021 11:12:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13AB460C41 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kOq0zTQeLvE1sZmElzJWVLP5g2AmRtQrF+aYmaS7wqk=; b=NDSZCfv/aV1b2qrFjLJ6imgoq8 ylJvwHLBE3XMmjQqwOpF9TDNq7hSR7JyesDxQlnwZLjd1lpowxcXGWBX42gdhytl+IKcRro4gJXh+ qXeC3T8w0op7tqmJ+ApO1MXIofpM7bJRE8I7ywyFXSoQuEpS8JS0BYbKugqjTC945QCUmpWSrKG8O GCv1SCbqxoV4HFBWUBCTJtrUjh8qsVl39xE1I6ZurO7WCNc0Z/dxpeXufIg2lFZ8oeqHmoOhqMQW9 Q7iHfdCS2YWe8cO4rTlQLeHpJjeHNdpEvWASyYSpbsWbSQKgY5gyBAa+slkldg7/IpDWjR3zYSCjb 16c95gyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltTRU-005zJN-Oj; Wed, 16 Jun 2021 11:10:44 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltTRQ-005zIp-Gu for linux-arm-kernel@lists.infradead.org; Wed, 16 Jun 2021 11:10:42 +0000 Received: from [192.168.254.32] (unknown [47.187.214.213]) by linux.microsoft.com (Postfix) with ESMTPSA id D8DCE20B6C50; Wed, 16 Jun 2021 04:10:37 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D8DCE20B6C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623841838; bh=WUztDHkRTHMvJT4FbhrMu1omm7Qd16h31ex9As3+QBk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=RuhaHoW4wskuJllTYrUI5HXLIHDc2rQajM4zq7x/Ly2YWl8D0BGfSZH5xwaNy/9GC 4NwKPLa2flFfs40lGzufd1Zg51BjhDIy7BGbDrjBxXb44DUtdett3ldRCrVQ9ZUZ2N xiZPhS0gLufvNqSTAxqShGWcuiXofBQk3atkSKik= Subject: Re: [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list To: Suraj Jitindar Singh , broonie@kernel.org, mark.rutland@arm.com, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, pasha.tatashin@soleen.com, jthierry@redhat.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210526214917.20099-1-madvenka@linux.microsoft.com> <20210526214917.20099-3-madvenka@linux.microsoft.com> <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> From: "Madhavan T. Venkataraman" Message-ID: Date: Wed, 16 Jun 2021 06:10:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210616_041040_730292_02ADBBCA X-CRM114-Status: GOOD ( 28.27 ) 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 6/15/21 8:52 PM, Suraj Jitindar Singh wrote: > On Wed, 2021-05-26 at 16:49 -0500, madvenka@linux.microsoft.com wrote: >> From: "Madhavan T. Venkataraman" >> >> The unwinder should check if the return PC falls in any function that >> is considered unreliable from an unwinding perspective. If it does, >> mark the stack trace unreliable. >> > > [snip] > > Correct me if I'm wrong, but do you not need to move the final frame > check to before the unwinder_is_unreliable() call? > That is done in a patch series that has been merged into for-next/stacktrace branch. When I merge this patch series with that, the final frame check will be done prior. I have mentioned this in the cover letter: Last stack frame ================ If a SYM_CODE function occurs in the very last frame in the stack trace, then the stack trace is not considered unreliable. This is because there is no more unwinding to do. Examples: - EL0 exception stack traces end in the top level EL0 exception handlers. - All kernel thread stack traces end in ret_from_fork(). Madhavan > Userland threads which have ret_from_fork as the last entry on the > stack will always be marked unreliable as they will always have a > SYM_CODE entry on their stack (the ret_from_fork). > > Also given that this means the last frame has been reached and as such > there's no more unwinding to do, I don't think we care if the last pc > is a code address. > > - Suraj > >> * >> @@ -133,7 +236,20 @@ int notrace unwind_frame(struct task_struct >> *tsk, struct stackframe *frame) >> * - Foreign code (e.g. EFI runtime services) >> * - Procedure Linkage Table (PLT) entries and veneer >> functions >> */ >> - if (!__kernel_text_address(frame->pc)) >> + if (!__kernel_text_address(frame->pc)) { >> + frame->reliable = false; >> + return 0; >> + } >> + >> + /* >> + * If the final frame has been reached, there is no more >> unwinding >> + * to do. There is no need to check if the return PC is >> considered >> + * unreliable by the unwinder. >> + */ >> + if (!frame->fp) >> + return 0; > > if (frame->fp == (unsigned long)task_pt_regs(tsk)->stackframe) > return -ENOENT; > >> + >> + if (unwinder_is_unreliable(frame->pc)) >> frame->reliable = false; >> >> return 0; >> diff --git a/arch/arm64/kernel/vmlinux.lds.S >> b/arch/arm64/kernel/vmlinux.lds.S >> index 7eea7888bb02..32e8d57397a1 100644 >> --- a/arch/arm64/kernel/vmlinux.lds.S >> +++ b/arch/arm64/kernel/vmlinux.lds.S >> @@ -103,6 +103,12 @@ jiffies = jiffies_64; >> #define TRAMP_TEXT >> #endif >> >> +#define SYM_CODE_FUNCTIONS \ >> + . = ALIGN(16); \ >> + __sym_code_functions_start = .; \ >> + KEEP(*(sym_code_functions)) \ >> + __sym_code_functions_end = .; >> + >> /* >> * The size of the PE/COFF section that covers the kernel image, >> which >> * runs from _stext to _edata, must be a round multiple of the >> PE/COFF >> @@ -218,6 +224,7 @@ SECTIONS >> CON_INITCALL >> INIT_RAM_FS >> *(.init.altinstructions .init.bss) /* from the >> EFI stub */ >> + SYM_CODE_FUNCTIONS >> } >> .exit.data : { >> EXIT_DATA _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel