From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754664AbdBGR4w (ORCPT ); Tue, 7 Feb 2017 12:56:52 -0500 Received: from foss.arm.com ([217.140.101.70]:59150 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412AbdBGR4v (ORCPT ); Tue, 7 Feb 2017 12:56:51 -0500 Date: Tue, 7 Feb 2017 17:55:42 +0000 From: Mark Rutland To: Peter Zijlstra Cc: Kees Cook , "Reshetova, Elena" , Greg KH , Arnd Bergmann , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Will Deacon , David Windsor , Hans Liljestrand , David Howells , LKML , "kernel-hardening@lists.openwall.com" Subject: Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Message-ID: <20170207175542.GC26173@leverpostej> References: <20170206085739.GH6515@twins.programming.kicks-ass.net> <20170207083405.GV6500@twins.programming.kicks-ass.net> <20170207111011.GB28790@leverpostej> <20170207123630.GR6515@twins.programming.kicks-ass.net> <20170207135020.GA26173@leverpostej> <20170207150737.GM25813@worktop.programming.kicks-ass.net> <20170207160300.GB26173@leverpostej> <20170207173036.GS6515@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170207173036.GS6515@twins.programming.kicks-ass.net> 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 Tue, Feb 07, 2017 at 06:30:36PM +0100, Peter Zijlstra wrote: > On Tue, Feb 07, 2017 at 04:03:01PM +0000, Mark Rutland wrote: > > For x86 it's a little painful due to '%' in the register names, but it looks > > possible. The below appears to do the mangling correctly (then screams due to > > the mangled result being nonexistent). > > > asm( > > " .macro reg_to_offset r\n" > > " .irp rs,eax,ebx,ecx,edx\n" > > " .ifc \\r, %\\rs\n" > > " __offset_of_\\rs\n" > > " .endif\n" > > " .endr\n" > > " .endm\n" > > ); > > > > #define asm_sym(var) asm volatile("reg_to_offset %0\n" : : "r" (var)) > > Oh gawd that's a most gnarly hack. :) > Do we want to go do that for all archs or somehow cook a generic > fallback that ends up doing a full function call or something? Given the arch-specific reg->blah mapping is so "fun", I guess a generic fallback would be a good start. I haven't figured out all the plumbing details. It'd be nice to reuse the bug infrastructure so that arches don't have to implement another trap and callback pair, but I guess the reg details need to live in another data structure. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 7 Feb 2017 17:55:42 +0000 From: Mark Rutland Message-ID: <20170207175542.GC26173@leverpostej> References: <20170206085739.GH6515@twins.programming.kicks-ass.net> <20170207083405.GV6500@twins.programming.kicks-ass.net> <20170207111011.GB28790@leverpostej> <20170207123630.GR6515@twins.programming.kicks-ass.net> <20170207135020.GA26173@leverpostej> <20170207150737.GM25813@worktop.programming.kicks-ass.net> <20170207160300.GB26173@leverpostej> <20170207173036.GS6515@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170207173036.GS6515@twins.programming.kicks-ass.net> Subject: Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION To: Peter Zijlstra Cc: Kees Cook , "Reshetova, Elena" , Greg KH , Arnd Bergmann , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Will Deacon , David Windsor , Hans Liljestrand , David Howells , LKML , "kernel-hardening@lists.openwall.com" List-ID: On Tue, Feb 07, 2017 at 06:30:36PM +0100, Peter Zijlstra wrote: > On Tue, Feb 07, 2017 at 04:03:01PM +0000, Mark Rutland wrote: > > For x86 it's a little painful due to '%' in the register names, but it looks > > possible. The below appears to do the mangling correctly (then screams due to > > the mangled result being nonexistent). > > > asm( > > " .macro reg_to_offset r\n" > > " .irp rs,eax,ebx,ecx,edx\n" > > " .ifc \\r, %\\rs\n" > > " __offset_of_\\rs\n" > > " .endif\n" > > " .endr\n" > > " .endm\n" > > ); > > > > #define asm_sym(var) asm volatile("reg_to_offset %0\n" : : "r" (var)) > > Oh gawd that's a most gnarly hack. :) > Do we want to go do that for all archs or somehow cook a generic > fallback that ends up doing a full function call or something? Given the arch-specific reg->blah mapping is so "fun", I guess a generic fallback would be a good start. I haven't figured out all the plumbing details. It'd be nice to reuse the bug infrastructure so that arches don't have to implement another trap and callback pair, but I guess the reg details need to live in another data structure. Thanks, Mark.