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=-9.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 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 188A3C48BE5 for ; Wed, 16 Jun 2021 01:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 038B561076 for ; Wed, 16 Jun 2021 01:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbhFPByK (ORCPT ); Tue, 15 Jun 2021 21:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhFPByI (ORCPT ); Tue, 15 Jun 2021 21:54:08 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD159C061574; Tue, 15 Jun 2021 18:52:03 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id w31so646230pga.6; Tue, 15 Jun 2021 18:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:in-reply-to:references:mime-version :content-transfer-encoding; bh=SYAZiKhu2cUPFls/xCgRwEt5H3IOQudDC2d2SMNfX8s=; b=tlwwglVZtYsipluaBFVpfWks6ENBb6VU0iFSnteE3nzK+y1kuem4YIfWfhTgUbgAmh xHErugfjlb/QUH7t2RDNjYYgSyiSQ9x2hfyb/8aA+LbPJFmhK854tvPnkoIp7zuXLCLV AEZSDDYo7azBdclJ5BOSonknsp5XAHaAmUi+n3iNDVcvxwRhbmMMoVMTaSM/Fmia0NS5 wRX1GH/Q6g+awuiW1oBoDNL0GXPWUF7XkL5RXWg7nheuEGdyaCWv03EIApuV0pUJhwmL ZZjlyJU+hLJX+FcDu5QNj45DiyEiHMqyKYqKRGP1U1Xno7P9KIj/7e/IzKhnVafHPxwA IL8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=SYAZiKhu2cUPFls/xCgRwEt5H3IOQudDC2d2SMNfX8s=; b=Ab5qzXp9cb+FIANXc0mWXb9UeP4lOPjqzOCj5wfflLgO329XlP2Q6PJk9243tqZxA/ CZdkQVPQaQ5F6T52ARZlXom5DvS8aJiP0pJAQ0jCb0ozwncTQx53cpUGMv/ezmvUJucY shWh92CHZFKSgeSnN4NONXI56A7ntrl82QZqvf3QKnypNebqNGYzcKqe57toa49yU1qC lZJoHc9pVjYPsk3xwZb64i3VWoUKwf79CDwTLghto9ZckQU+tDuzEoSzv7W63kGetKBy Sj4E7picNmpW6KyyBjKpIyMEKGAJ7HEFtf6dUgIymd+hTAhTTKr0g8USCHaOaX7cpZno RF1A== X-Gm-Message-State: AOAM5332T0EXzcvaoQ6Iw8hUcKTAb0G3TJAeaLbrwAuN1KiFiYVrH6iu HW6U7EEuSHqoerg+rQuU/OM= X-Google-Smtp-Source: ABdhPJxTguLZTyee9M/iAjORC96v1PnwIMeyIKIZKeZzSHQ6/GXDMDaCa6prXtWLjoLl3QrHo9tkig== X-Received: by 2002:a63:78d:: with SMTP id 135mr2539279pgh.178.1623808323335; Tue, 15 Jun 2021 18:52:03 -0700 (PDT) Received: from u3c3f5cfe23135f.ant.amazon.com (97-113-131-35.tukw.qwest.net. [97.113.131.35]) by smtp.googlemail.com with ESMTPSA id q21sm3459664pjg.43.2021.06.15.18.52.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:52:02 -0700 (PDT) Message-ID: <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> Subject: Re: [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list From: Suraj Jitindar Singh To: madvenka@linux.microsoft.com, 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 Date: Tue, 15 Jun 2021 18:52:01 -0700 In-Reply-To: <20210526214917.20099-3-madvenka@linux.microsoft.com> References: <20210526214917.20099-1-madvenka@linux.microsoft.com> <20210526214917.20099-3-madvenka@linux.microsoft.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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 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=-7.2 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no 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 A1D3FC48BDF for ; Wed, 16 Jun 2021 01:53:34 +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 54ACB61076 for ; Wed, 16 Jun 2021 01:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54ACB61076 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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:Mime-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hVX42zXbN9W2SXhrndEnxjTuZzRnXGUwll2peuXS3/U=; b=fzDXs4G/tQk+z9 XQJY/xoSDEZZF9p1I+prAgpP0LkW2BZ62vMmpsswt2KvQ5nodxfL51GScs+v5tL0NBQjQX1VKl56N FszAbbaGKhN8HPZ9Mk1ye87a1VeLBlrKGx1H467BXJrYZQE6YW/SboX7crCWTP6UNO0Us/ISSyL0x 6AbfkWWlUxDFGgeRlVTTii7Gb5nB4dRRUDljSKMf3WKL3IfLW9a/43MFC9BgCoUsQzO9tEU3fxE07 aAp9RWhJB69kcRZ35uFvf7zlNsu4HXqBk/+fNPlE4wGz/o0BcHpWOM0V+n5goI18Djmab0dy8EucD LUaoOisY5F2h37dkIwNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltKiv-004PGr-6D; Wed, 16 Jun 2021 01:52:09 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltKiq-004PGA-I8 for linux-arm-kernel@lists.infradead.org; Wed, 16 Jun 2021 01:52:06 +0000 Received: by mail-pf1-x431.google.com with SMTP id c12so907113pfl.3 for ; Tue, 15 Jun 2021 18:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:in-reply-to:references:mime-version :content-transfer-encoding; bh=SYAZiKhu2cUPFls/xCgRwEt5H3IOQudDC2d2SMNfX8s=; b=tlwwglVZtYsipluaBFVpfWks6ENBb6VU0iFSnteE3nzK+y1kuem4YIfWfhTgUbgAmh xHErugfjlb/QUH7t2RDNjYYgSyiSQ9x2hfyb/8aA+LbPJFmhK854tvPnkoIp7zuXLCLV AEZSDDYo7azBdclJ5BOSonknsp5XAHaAmUi+n3iNDVcvxwRhbmMMoVMTaSM/Fmia0NS5 wRX1GH/Q6g+awuiW1oBoDNL0GXPWUF7XkL5RXWg7nheuEGdyaCWv03EIApuV0pUJhwmL ZZjlyJU+hLJX+FcDu5QNj45DiyEiHMqyKYqKRGP1U1Xno7P9KIj/7e/IzKhnVafHPxwA IL8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=SYAZiKhu2cUPFls/xCgRwEt5H3IOQudDC2d2SMNfX8s=; b=TL5WdAoYVMfqmzTW8/M+sIQiKVrTxaJdmCqFtx5Fc8RaPiFu2puHhhs18IKI3/T9/3 CzrAkxLHIlOGSkHypj7c3nmF5vhkXWYZnD0ssM3duzkLBMHf3GJpxSNfEjusbUsFxn6F WTxVEpnEHIBBXhQydxZRSzSJosZg1V7N2LiiICPsuhgYr4Y9E2Vl+r44voSEvyw9tzYR GikULRMI2vdRWttv7+xWEHAhn+OjzlZzk22hGEwhj38aWKoQpxc6NMSWQ2uKxWBeLykw z9r60FGniHHijf/laIVuAai6DWKmAcR61YBYVzknjs1YB0rRl4kzf7P/AG8sFKqMH9K1 jsvw== X-Gm-Message-State: AOAM530AO1o95WzRi/1PdU9J0F7AKDauc/8u/itOBlnGigcgxo7CZ4QX fuLzusKXSZGihIP9TySlbLhZ+14Zslo= X-Google-Smtp-Source: ABdhPJxTguLZTyee9M/iAjORC96v1PnwIMeyIKIZKeZzSHQ6/GXDMDaCa6prXtWLjoLl3QrHo9tkig== X-Received: by 2002:a63:78d:: with SMTP id 135mr2539279pgh.178.1623808323335; Tue, 15 Jun 2021 18:52:03 -0700 (PDT) Received: from u3c3f5cfe23135f.ant.amazon.com (97-113-131-35.tukw.qwest.net. [97.113.131.35]) by smtp.googlemail.com with ESMTPSA id q21sm3459664pjg.43.2021.06.15.18.52.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:52:02 -0700 (PDT) Message-ID: <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> Subject: Re: [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list From: Suraj Jitindar Singh To: madvenka@linux.microsoft.com, 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 Date: Tue, 15 Jun 2021 18:52:01 -0700 In-Reply-To: <20210526214917.20099-3-madvenka@linux.microsoft.com> References: <20210526214917.20099-1-madvenka@linux.microsoft.com> <20210526214917.20099-3-madvenka@linux.microsoft.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_185204_685879_E6CB047B X-CRM114-Status: GOOD ( 28.16 ) 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 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? 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