From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751905AbdF3I1V (ORCPT ); Fri, 30 Jun 2017 04:27:21 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33672 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbdF3I1H (ORCPT ); Fri, 30 Jun 2017 04:27:07 -0400 MIME-Version: 1.0 In-Reply-To: References: <1495829844-69341-1-git-send-email-keescook@chromium.org> <1495829844-69341-5-git-send-email-keescook@chromium.org> From: Arnd Bergmann Date: Fri, 30 Jun 2017 10:27:06 +0200 X-Google-Sender-Auth: 42DxH9sAS4lImmOeS0CVY70Hhk8 Message-ID: Subject: Re: [PATCH v2 04/20] gcc-plugins: Add the randstruct plugin To: Ard Biesheuvel Cc: Kees Cook , Kernel Hardening , Laura Abbott , "the arch/x86 maintainers" , Linux Kernel Mailing List , Russell King - ARM Linux , Nicolas Pitre , Will Deacon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 30, 2017 at 9:55 AM, Ard Biesheuvel wrote: > On 30 June 2017 at 07:35, Arnd Bergmann wrote: >> On Fri, Jun 30, 2017 at 12:53 AM, Kees Cook wrote: >>> The first obviously won't fly. The second just bypasses the problem >>> forcing it to be exposed by other people later. The third is likely >>> easiest to do now, but reduces the effectiveness of randomization for >>> architectures that don't have sensitive immediate values. The fourth >>> sounds not generally useful. The fifth may be unacceptable to arm >>> maintainers due to performance impacts. >> >> I was thinking of the fifth solution, but don't know exactly how to >> do it. If performance is a concern, I guess we could have separate >> implementations for randstruct and traditional builds. >> > > Does this not apply to *all* entries in asm-offsets? If so, I don't > see how it is tractable to fix this in the code, unless we add some > instrumentation to asm-offsets to whitelist some huge structs and > error out on new ones. Or perhaps there's really only a handful? I think the other structs are all small enough: * thread_info is at most 720 bytes (including crunch+vfp3, which you wouldn't find in one combined kernel) and not randomized at the moment * pt_regs is 72 bytes and I don't see how that would be randomized * machine_desc would be a candidate for randomizing, but is only 108 bytes * proc_info_list is 52 bytes and not currently randomized * vm_area_struct is randomized but only 96 bytes. * task_struct is clearly large enough, but we only use TSK_ACTIVE_MM and TSK_STACK_CANARY, both can be fixed with your trick. > In any case, these particular examples are fairly straightforward, > since there is no need to preserve the register's value. > > ldr r7, [r7, #TSK_STACK_CANARY] > > could be replaced with > > .if TSK_STACK_CANARAY >= PAGE_SIZE > add r7, r7, #TSK_STACK_CANARY & PAGE_MASK > .endif > ldr r7, [r7, #TSK_STACK_CANARY & ~PAGE_MASK] Nice! Arnd