From: Suraj Jitindar Singh <sjitindarsingh@gmail.com> 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 Subject: Re: [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list Date: Tue, 15 Jun 2021 18:52:01 -0700 [thread overview] Message-ID: <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> (raw) In-Reply-To: <20210526214917.20099-3-madvenka@linux.microsoft.com> On Wed, 2021-05-26 at 16:49 -0500, madvenka@linux.microsoft.com wrote: > From: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com> > > 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
WARNING: multiple messages have this Message-ID (diff)
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com> 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 Subject: Re: [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list Date: Tue, 15 Jun 2021 18:52:01 -0700 [thread overview] Message-ID: <712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com> (raw) In-Reply-To: <20210526214917.20099-3-madvenka@linux.microsoft.com> On Wed, 2021-05-26 at 16:49 -0500, madvenka@linux.microsoft.com wrote: > From: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com> > > 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
next prev parent reply other threads:[~2021-06-16 1:52 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <ea0ef9ed6eb34618bcf468fbbf8bdba99e15df7d> 2021-05-26 21:49 ` [RFC PATCH v5 0/2] arm64: Implement stack trace reliability checks madvenka 2021-05-26 21:49 ` madvenka 2021-05-26 21:49 ` [RFC PATCH v5 1/2] arm64: Introduce stack trace reliability checks in the unwinder madvenka 2021-05-26 21:49 ` madvenka 2021-06-24 14:40 ` Mark Rutland 2021-06-24 14:40 ` Mark Rutland 2021-06-24 16:03 ` Mark Brown 2021-06-24 16:03 ` Mark Brown 2021-06-25 15:39 ` Madhavan T. Venkataraman 2021-06-25 15:39 ` Madhavan T. Venkataraman 2021-06-25 15:51 ` Mark Brown 2021-06-25 15:51 ` Mark Brown 2021-06-25 17:05 ` Madhavan T. Venkataraman 2021-06-25 17:05 ` Madhavan T. Venkataraman 2021-06-25 17:18 ` Madhavan T. Venkataraman 2021-06-25 17:18 ` Madhavan T. Venkataraman 2021-06-26 15:35 ` Madhavan T. Venkataraman 2021-06-26 15:35 ` Madhavan T. Venkataraman 2021-06-29 16:47 ` Josh Poimboeuf 2021-06-29 16:47 ` Josh Poimboeuf 2021-05-26 21:49 ` [RFC PATCH v5 2/2] arm64: Create a list of SYM_CODE functions, check return PC against list madvenka 2021-05-26 21:49 ` madvenka 2021-06-04 16:24 ` Mark Brown 2021-06-04 16:24 ` Mark Brown 2021-06-04 20:38 ` Madhavan T. Venkataraman 2021-06-04 20:38 ` Madhavan T. Venkataraman 2021-06-04 16:59 ` Mark Brown 2021-06-04 16:59 ` Mark Brown 2021-06-04 20:40 ` Madhavan T. Venkataraman 2021-06-04 20:40 ` Madhavan T. Venkataraman 2021-06-16 1:52 ` Suraj Jitindar Singh [this message] 2021-06-16 1:52 ` Suraj Jitindar Singh 2021-06-16 9:15 ` nobuta.keiya 2021-06-16 9:15 ` nobuta.keiya 2021-06-16 11:10 ` Madhavan T. Venkataraman 2021-06-16 11:10 ` Madhavan T. Venkataraman 2021-06-04 15:29 ` [RFC PATCH v5 0/2] arm64: Implement stack trace reliability checks Mark Brown 2021-06-04 15:29 ` Mark Brown 2021-06-04 20:44 ` Madhavan T. Venkataraman 2021-06-04 20:44 ` Madhavan T. Venkataraman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=712b44d2af8f8cd3199aad87eb3bc94ea22d6f4a.camel@gmail.com \ --to=sjitindarsingh@gmail.com \ --cc=ardb@kernel.org \ --cc=broonie@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=jmorris@namei.org \ --cc=jpoimboe@redhat.com \ --cc=jthierry@redhat.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=live-patching@vger.kernel.org \ --cc=madvenka@linux.microsoft.com \ --cc=mark.rutland@arm.com \ --cc=nobuta.keiya@fujitsu.com \ --cc=pasha.tatashin@soleen.com \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.