From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753707AbdK1EzT (ORCPT ); Mon, 27 Nov 2017 23:55:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45116 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752538AbdK1EzS (ORCPT ); Mon, 27 Nov 2017 23:55:18 -0500 Date: Mon, 27 Nov 2017 22:55:16 -0600 From: Josh Poimboeuf To: Borislav Petkov Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Dave Hansen , Andy Lutomirski , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , Linus Torvalds Subject: Re: [PATCH 02/21] x86/unwinder: Handle stack overflows more gracefully Message-ID: <20171128045516.almy3bve5qafb6bk@treble> References: <20171127104529.12435-1-mingo@kernel.org> <20171127104529.12435-3-mingo@kernel.org> <20171127173604.eff4ta576mpxjhjg@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171127173604.eff4ta576mpxjhjg@pd.tnic> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 28 Nov 2017 04:55:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 27, 2017 at 06:36:04PM +0100, Borislav Petkov wrote: > > +static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr, > > + unsigned long *ip, unsigned long *sp) > > +{ > > + struct pt_regs *regs = (void *)addr - IRET_FRAME_OFFSET; > > I guess those are traditionally done with container_of()... Without modifying pt_regs, there's no container to speak of, but at least IRET_FRAME_OFFSET uses offsetof(), which is similar. > But yeah, FWIW, looks ok to me: > > Reviewed-by: Borislav Petkov Thanks! Ingo, can you fold in the below changes based on Boris' comments? diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 5be2fb23825a..c1688c2d0a12 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -57,7 +57,7 @@ void unwind_start(struct unwind_state *state, struct task_struct *task, #if defined(CONFIG_UNWINDER_ORC) || defined(CONFIG_UNWINDER_FRAME_POINTER) /* * WARNING: The entire pt_regs may not be safe to dereference. In some cases, - * only the iret registers are accessible. Use with caution! + * only the iret frame registers are accessible. Use with caution! */ static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) { diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index fc918744ad7d..0bc95be5c638 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -66,7 +66,7 @@ static void show_regs_safe(struct stack_info *info, struct pt_regs *regs) /* * When an interrupt or exception occurs in entry code, the * full pt_regs might not have been saved yet. In that case - * just print the iret return frame. + * just print the iret frame. */ show_iret_regs(regs); }