All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Kees Cook <keescook@chromium.org>,
	Kernel Hardening <kernel-hardening@lists.openwall.com>,
	Laura Abbott <labbott@redhat.com>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH v2 04/20] gcc-plugins: Add the randstruct plugin
Date: Fri, 30 Jun 2017 10:27:06 +0200	[thread overview]
Message-ID: <CAK8P3a076DEDpzRgTRBNLWan-KZyD0LkauWpuO8RFCf-9i1mhA@mail.gmail.com> (raw)
In-Reply-To: <CAKv+Gu-EWyfB3zbPwT9=bLwR0GDtg5mwKaD0p5AbssjbxU7sMA@mail.gmail.com>

On Fri, Jun 30, 2017 at 9:55 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> On 30 June 2017 at 07:35, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Fri, Jun 30, 2017 at 12:53 AM, Kees Cook <keescook@chromium.org> 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

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Kees Cook <keescook@chromium.org>,
	Kernel Hardening <kernel-hardening@lists.openwall.com>,
	Laura Abbott <labbott@redhat.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Will Deacon <will.deacon@arm.com>
Subject: [kernel-hardening] Re: [PATCH v2 04/20] gcc-plugins: Add the randstruct plugin
Date: Fri, 30 Jun 2017 10:27:06 +0200	[thread overview]
Message-ID: <CAK8P3a076DEDpzRgTRBNLWan-KZyD0LkauWpuO8RFCf-9i1mhA@mail.gmail.com> (raw)
In-Reply-To: <CAKv+Gu-EWyfB3zbPwT9=bLwR0GDtg5mwKaD0p5AbssjbxU7sMA@mail.gmail.com>

On Fri, Jun 30, 2017 at 9:55 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> On 30 June 2017 at 07:35, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Fri, Jun 30, 2017 at 12:53 AM, Kees Cook <keescook@chromium.org> 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

  reply	other threads:[~2017-06-30  8:27 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 20:17 [PATCH v2 00/20] Introduce struct layout randomization plugin Kees Cook
2017-05-26 20:17 ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 01/20] NFS: Avoid cross-structure casting Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-28  7:53   ` Christoph Hellwig
2017-05-28  7:53     ` [kernel-hardening] " Christoph Hellwig
2017-05-28 16:55     ` Kees Cook
2017-05-28 16:55       ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 02/20] gcc-plugins: Detail c-common.h location for GCC 4.6 Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 03/20] compiler: Add __designated_init annotation Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 04/20] gcc-plugins: Add the randstruct plugin Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-06-29 22:08   ` Arnd Bergmann
2017-06-29 22:08     ` [kernel-hardening] " Arnd Bergmann
2017-06-29 22:53     ` Kees Cook
2017-06-29 22:53       ` [kernel-hardening] " Kees Cook
2017-06-30  0:04       ` Kees Cook
2017-06-30  0:04         ` [kernel-hardening] " Kees Cook
2017-06-30  7:35       ` Arnd Bergmann
2017-06-30  7:35         ` [kernel-hardening] " Arnd Bergmann
2017-06-30  7:55         ` Ard Biesheuvel
2017-06-30  7:55           ` [kernel-hardening] " Ard Biesheuvel
2017-06-30  8:27           ` Arnd Bergmann [this message]
2017-06-30  8:27             ` Arnd Bergmann
2017-06-30 14:41             ` Kees Cook
2017-06-30 14:41               ` [kernel-hardening] " Kees Cook
2017-06-30 15:22               ` Arnd Bergmann
2017-06-30 15:22                 ` [kernel-hardening] " Arnd Bergmann
2017-05-26 20:17 ` [PATCH v2 05/20] randstruct: Whitelist struct security_hook_heads cast Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-27  8:41   ` Christoph Hellwig
2017-05-27  8:41     ` [kernel-hardening] " Christoph Hellwig
2017-05-27 20:09     ` Kees Cook
2017-05-27 20:09       ` [kernel-hardening] " Kees Cook
2017-05-27 20:09       ` Kees Cook
2017-05-27 22:04       ` Tetsuo Handa
2017-05-27 22:04         ` [kernel-hardening] " Tetsuo Handa
2017-05-27 22:04         ` Tetsuo Handa
2017-05-28  0:43         ` [kernel-hardening] " Kees Cook
2017-05-28  0:43           ` Kees Cook
2017-05-28  0:43           ` Kees Cook
2017-05-30 10:34       ` James Morris
2017-05-30 10:34         ` [kernel-hardening] " James Morris
2017-05-30 10:34         ` James Morris
2017-05-26 20:17 ` [PATCH v2 06/20] randstruct: Whitelist UNIXCB cast Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:20   ` Kees Cook
2017-05-26 20:20     ` [kernel-hardening] " Kees Cook
2017-05-28  7:56   ` Christoph Hellwig
2017-05-28  7:56     ` [kernel-hardening] " Christoph Hellwig
2017-05-26 20:17 ` [PATCH v2 07/20] randstruct: Whitelist big_key path struct overloading Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-28  8:12   ` Christoph Hellwig
2017-05-28  8:12     ` [kernel-hardening] " Christoph Hellwig
2017-05-28 16:59     ` Kees Cook
2017-05-28 16:59       ` [kernel-hardening] " Kees Cook
2017-06-19 19:24       ` Kees Cook
2017-06-19 19:24         ` [kernel-hardening] " Kees Cook
2017-09-07  7:20         ` Christoph Hellwig
2017-09-07  7:20           ` [kernel-hardening] " Christoph Hellwig
2017-09-07 22:55           ` Kees Cook
2017-09-07 22:55             ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 08/20] randstruct: Whitelist NIU struct page overloading Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-28  8:15   ` Christoph Hellwig
2017-05-28  8:15     ` [kernel-hardening] " Christoph Hellwig
2017-05-28 17:35     ` Kees Cook
2017-05-28 17:35       ` [kernel-hardening] " Kees Cook
2017-05-28 17:35       ` Kees Cook
2017-05-28 17:37     ` Kees Cook
2017-05-28 17:37       ` [kernel-hardening] " Kees Cook
2017-05-28 17:37       ` Kees Cook
2017-05-26 20:17 ` [PATCH v2 09/20] randstruct: Mark various structs for randomization Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 10/20] randstruct: opt-out externally exposed function pointer structs Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 11/20] randstruct: Disable randomization of ACPICA structs Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-27  8:42   ` Christoph Hellwig
2017-05-27  8:42     ` [kernel-hardening] " Christoph Hellwig
2017-05-27 20:03     ` Kees Cook
2017-05-27 20:03       ` [kernel-hardening] " Kees Cook
2017-05-28  4:55       ` Christoph Hellwig
2017-05-28  4:55         ` [kernel-hardening] " Christoph Hellwig
2017-05-26 20:17 ` [PATCH v2 12/20] sgi-xp: Use designated initializers Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-27  8:44   ` Christoph Hellwig
2017-05-27  8:44     ` [kernel-hardening] " Christoph Hellwig
2017-05-26 20:17 ` [PATCH v2 13/20] drm/amdgpu: " Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 14/20] drm/amd/powerplay: " Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-27  8:47   ` Christoph Hellwig
2017-05-27  8:47     ` [kernel-hardening] " Christoph Hellwig
2017-05-27 20:10     ` Kees Cook
2017-05-27 20:10       ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 15/20] mtk-vcodec: " Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 16/20] ntfs: Use ERR_CAST() to avoid cross-structure cast Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 17/20] ocfs2: " Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 18/20] randstruct: Enable function pointer struct detection Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 19/20] [RFC] task_struct: Allow randomized layout Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-26 20:23   ` Linus Torvalds
2017-05-26 20:23     ` [kernel-hardening] " Linus Torvalds
2017-05-26 20:32     ` Kees Cook
2017-05-26 20:32       ` [kernel-hardening] " Kees Cook
2017-05-26 20:17 ` [PATCH v2 20/20] ACPICA: Use designated initializers Kees Cook
2017-05-26 20:17   ` [kernel-hardening] " Kees Cook
2017-05-28  7:45   ` Christoph Hellwig
2017-05-28  7:45     ` [kernel-hardening] " Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a076DEDpzRgTRBNLWan-KZyD0LkauWpuO8RFCf-9i1mhA@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=ard.biesheuvel@linaro.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nicolas.pitre@linaro.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.