From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754418AbdGNP0D (ORCPT ); Fri, 14 Jul 2017 11:26:03 -0400 Received: from foss.arm.com ([217.140.101.70]:49942 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754031AbdGNP0C (ORCPT ); Fri, 14 Jul 2017 11:26:02 -0400 Date: Fri, 14 Jul 2017 16:25:03 +0100 From: Mark Rutland To: Robin Murphy Cc: Ard Biesheuvel , Kees Cook , Kernel Hardening , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , James Morse , Takahiro Akashi , Dave Martin , "linux-arm-kernel@lists.infradead.org" , Laura Abbott Subject: Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Message-ID: <20170714152503.GC16687@leverpostej> References: <20170713161050.GG26194@leverpostej> <20170713175543.GA32528@leverpostej> <20170714103258.GA16128@leverpostej> <20170714140605.GB16687@leverpostej> <188731af-269c-4197-1c55-78e485e7af46@arm.com> <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 14, 2017 at 04:03:51PM +0100, Robin Murphy wrote: > On 14/07/17 15:39, Robin Murphy wrote: > > On 14/07/17 15:06, Mark Rutland wrote: > >> add sp, sp, x0 // sp = orig_sp + orig_x0 > >> sub x0, sp, x0 // x0 = orig_sp > >> < check > > >> sub x0, sp, x0 // x0 = orig_x0 > > > > Haven't you now forcibly cleared the top bit of x0 thanks to overflow? > > ...or maybe not. I still can't quite see it, but I suppose it must > cancel out somewhere, since Mr. Helpful C Program[1] has apparently > proven me mistaken :( > > I guess that means I approve! > > Robin. > > [1]: > #include > #include > > int main(void) { > for (int i = 0; i < 256; i++) { > for (int j = 0; j < 256; j++) { > uint8_t x = i; > uint8_t y = j; > y = y + x; > x = y - x; > x = y - x; > y = y - x; > assert(x == i && y == j); > } > } > } I guess we have our first Tested-by for this series. :) Thanks for taking a look! Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 From: mark.rutland@arm.com (Mark Rutland) Date: Fri, 14 Jul 2017 16:25:03 +0100 Subject: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP In-Reply-To: <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> References: <20170713161050.GG26194@leverpostej> <20170713175543.GA32528@leverpostej> <20170714103258.GA16128@leverpostej> <20170714140605.GB16687@leverpostej> <188731af-269c-4197-1c55-78e485e7af46@arm.com> <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> Message-ID: <20170714152503.GC16687@leverpostej> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Jul 14, 2017 at 04:03:51PM +0100, Robin Murphy wrote: > On 14/07/17 15:39, Robin Murphy wrote: > > On 14/07/17 15:06, Mark Rutland wrote: > >> add sp, sp, x0 // sp = orig_sp + orig_x0 > >> sub x0, sp, x0 // x0 = orig_sp > >> < check > > >> sub x0, sp, x0 // x0 = orig_x0 > > > > Haven't you now forcibly cleared the top bit of x0 thanks to overflow? > > ...or maybe not. I still can't quite see it, but I suppose it must > cancel out somewhere, since Mr. Helpful C Program[1] has apparently > proven me mistaken :( > > I guess that means I approve! > > Robin. > > [1]: > #include > #include > > int main(void) { > for (int i = 0; i < 256; i++) { > for (int j = 0; j < 256; j++) { > uint8_t x = i; > uint8_t y = j; > y = y + x; > x = y - x; > x = y - x; > y = y - x; > assert(x == i && y == j); > } > } > } I guess we have our first Tested-by for this series. :) Thanks for taking a look! Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 14 Jul 2017 16:25:03 +0100 From: Mark Rutland Message-ID: <20170714152503.GC16687@leverpostej> References: <20170713161050.GG26194@leverpostej> <20170713175543.GA32528@leverpostej> <20170714103258.GA16128@leverpostej> <20170714140605.GB16687@leverpostej> <188731af-269c-4197-1c55-78e485e7af46@arm.com> <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f805a19-19d1-3c97-c85b-510664d22dad@arm.com> Subject: Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP To: Robin Murphy Cc: Ard Biesheuvel , Kees Cook , Kernel Hardening , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , James Morse , Takahiro Akashi , Dave Martin , "linux-arm-kernel@lists.infradead.org" , Laura Abbott List-ID: On Fri, Jul 14, 2017 at 04:03:51PM +0100, Robin Murphy wrote: > On 14/07/17 15:39, Robin Murphy wrote: > > On 14/07/17 15:06, Mark Rutland wrote: > >> add sp, sp, x0 // sp = orig_sp + orig_x0 > >> sub x0, sp, x0 // x0 = orig_sp > >> < check > > >> sub x0, sp, x0 // x0 = orig_x0 > > > > Haven't you now forcibly cleared the top bit of x0 thanks to overflow? > > ...or maybe not. I still can't quite see it, but I suppose it must > cancel out somewhere, since Mr. Helpful C Program[1] has apparently > proven me mistaken :( > > I guess that means I approve! > > Robin. > > [1]: > #include > #include > > int main(void) { > for (int i = 0; i < 256; i++) { > for (int j = 0; j < 256; j++) { > uint8_t x = i; > uint8_t y = j; > y = y + x; > x = y - x; > x = y - x; > y = y - x; > assert(x == i && y == j); > } > } > } I guess we have our first Tested-by for this series. :) Thanks for taking a look! Mark.