From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbcHLTPo (ORCPT ); Fri, 12 Aug 2016 15:15:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57760 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752713AbcHLTPm (ORCPT ); Fri, 12 Aug 2016 15:15:42 -0400 Date: Fri, 12 Aug 2016 14:15:37 -0500 From: Josh Poimboeuf To: Kees Cook Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "x86@kernel.org" , LKML , Andy Lutomirski , Linus Torvalds , Steven Rostedt , Brian Gerst , Peter Zijlstra , Frederic Weisbecker , Byungchul Park , Nilay Vaish Subject: Re: [PATCH v3 51/51] x86/mm: convert arch_within_stack_frames() to use the new unwinder Message-ID: <20160812191537.dilnu4s4gcnddt5h@treble> References: <20160812151723.b754g7btabokhvr5@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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.28]); Fri, 12 Aug 2016 19:15:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 12, 2016 at 10:38:31AM -0700, Kees Cook wrote: > On Fri, Aug 12, 2016 at 8:17 AM, Josh Poimboeuf wrote: > > On Fri, Aug 12, 2016 at 09:29:10AM -0500, Josh Poimboeuf wrote: > >> Convert arch_within_stack_frames() to use the new unwinder. > >> > >> Boot tested with CONFIG_HARDENED_USERCOPY. > >> > >> Signed-off-by: Josh Poimboeuf > >> --- > >> arch/x86/lib/usercopy.c | 25 +++++++++++++++++++------ > >> 1 file changed, 19 insertions(+), 6 deletions(-) > >> > >> diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c > >> index 96ce151..9d0913c 100644 > >> --- a/arch/x86/lib/usercopy.c > >> +++ b/arch/x86/lib/usercopy.c > >> @@ -50,12 +50,21 @@ int arch_within_stack_frames(const void * const stack, > >> const void * const stackend, > >> const void *obj, unsigned long len) > >> { > >> - const void *frame = NULL; > >> - const void *oldframe; > >> + struct unwind_state state; > >> + const void *frame, *oldframe; > >> + > >> + unwind_start(&state, current, NULL, NULL); > >> + > >> + if (!unwind_next_frame(&state)) > >> + return 0; > >> + > >> + oldframe = unwind_get_stack_ptr(&state); > > > > Actually, I think this isn't quite right. Now that the function isn't > > inlined, this needs to unwind another frame to be equivalent to current > > behavior. > > Yeah, that seems right. And IIUC, as long as this is wrapped in the > CONFIG_FRAME_POINTER check, this won't use the guessing unwinder, > right? (Which is how it should be.) Right, only the frame pointer unwinder will be used here, thanks to the CONFIG_FRAME_POINTER guard in thread_info.h. -- Josh