All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Laura Abbott <labbott@redhat.com>
Cc: Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org,
	catalin.marinas@arm.com, james.morse@arm.com,
	luto@amacapital.net, matt@codeblueprint.co.uk,
	will.deacon@arm.com, kernel-hardening@lists.openwall.com,
	linux-arm-kernel@lists.infradead.org
Subject: [kernel-hardening] Re: [PATCH] lkdtm: Test VMAP_STACK allocates leading/trailing guard pages
Date: Tue, 8 Aug 2017 10:23:48 +0100	[thread overview]
Message-ID: <20170808092348.GA19207@leverpostej> (raw)
In-Reply-To: <0e9a80c2-3e5e-db98-dff6-b45e9e4817fd@redhat.com>

On Mon, Aug 07, 2017 at 03:55:22PM -0700, Laura Abbott wrote:
> On 08/07/2017 03:00 PM, Mark Rutland wrote:
> > On Mon, Aug 07, 2017 at 01:39:48PM -0700, Kees Cook wrote:

> >> Do these tests both trip with the new arm64 VMAP_STACK code?
> > 
> >> +/* Test that VMAP_STACK is actually allocating with a leading guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_LEADING(void)

> >> +/* Test that VMAP_STACK is actually allocating with a trailing guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_TRAILING(void)

> > I can give these a go tomorrow.
> > 
> > These *should* fault, and IIUC should trigger the usual "Unable to handle
> > kernel %s at virtual address %08lx\n" splat from arm64's __do_kernel_fault(),
> > which should end up with an Oops().

> I gave these a quick test in QEMU and they seem to do the correct thing:

> # echo STACK_GUARD_PAGE_LEADING > /sys/kernel/debug/provoke-crash/DIRECT 
> [   24.593306] lkdtm: Performing direct entry STACK_GUARD_PAGE_LEADING
> [   24.593780] lkdtm: attempting bad read from page below current stack
> [   24.594289] Unable to handle kernel paging request at virtual address ffff000009b77fff
> [   24.594747] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [   24.595443] [ffff000009b77fff] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007cc43003, *pte=0000000000000000
> [   24.596743] Internal error: Oops: 96000007 [#1] PREEMPT SMP

> # echo STACK_GUARD_PAGE_TRAILING > /sys/kernel/debug/provoke-crash/DIRECT 
> [  103.144313] lkdtm: Performing direct entry STACK_GUARD_PAGE_TRAILING
> [  103.144749] lkdtm: attempting bad read from page above current stack
> [  103.145100] Unable to handle kernel paging request at virtual address ffff000009c2c000
> [  103.145477] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [  103.145836] [ffff000009c2c000] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007d014003, *pte=0000000000000000
> [  103.146445] Internal error: Oops: 96000007 [#2] PREEMPT SMP

Great! thanks for giving those a spin.

I can confirm likewise on Juno with 64K pages (not that this should make
any difference).

Mark.

WARNING: multiple messages have this Message-ID (diff)
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] lkdtm: Test VMAP_STACK allocates leading/trailing guard pages
Date: Tue, 8 Aug 2017 10:23:48 +0100	[thread overview]
Message-ID: <20170808092348.GA19207@leverpostej> (raw)
In-Reply-To: <0e9a80c2-3e5e-db98-dff6-b45e9e4817fd@redhat.com>

On Mon, Aug 07, 2017 at 03:55:22PM -0700, Laura Abbott wrote:
> On 08/07/2017 03:00 PM, Mark Rutland wrote:
> > On Mon, Aug 07, 2017 at 01:39:48PM -0700, Kees Cook wrote:

> >> Do these tests both trip with the new arm64 VMAP_STACK code?
> > 
> >> +/* Test that VMAP_STACK is actually allocating with a leading guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_LEADING(void)

> >> +/* Test that VMAP_STACK is actually allocating with a trailing guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_TRAILING(void)

> > I can give these a go tomorrow.
> > 
> > These *should* fault, and IIUC should trigger the usual "Unable to handle
> > kernel %s at virtual address %08lx\n" splat from arm64's __do_kernel_fault(),
> > which should end up with an Oops().

> I gave these a quick test in QEMU and they seem to do the correct thing:

> # echo STACK_GUARD_PAGE_LEADING > /sys/kernel/debug/provoke-crash/DIRECT 
> [   24.593306] lkdtm: Performing direct entry STACK_GUARD_PAGE_LEADING
> [   24.593780] lkdtm: attempting bad read from page below current stack
> [   24.594289] Unable to handle kernel paging request at virtual address ffff000009b77fff
> [   24.594747] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [   24.595443] [ffff000009b77fff] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007cc43003, *pte=0000000000000000
> [   24.596743] Internal error: Oops: 96000007 [#1] PREEMPT SMP

> # echo STACK_GUARD_PAGE_TRAILING > /sys/kernel/debug/provoke-crash/DIRECT 
> [  103.144313] lkdtm: Performing direct entry STACK_GUARD_PAGE_TRAILING
> [  103.144749] lkdtm: attempting bad read from page above current stack
> [  103.145100] Unable to handle kernel paging request at virtual address ffff000009c2c000
> [  103.145477] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [  103.145836] [ffff000009c2c000] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007d014003, *pte=0000000000000000
> [  103.146445] Internal error: Oops: 96000007 [#2] PREEMPT SMP

Great! thanks for giving those a spin.

I can confirm likewise on Juno with 64K pages (not that this should make
any difference).

Mark.

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Laura Abbott <labbott@redhat.com>
Cc: Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org,
	catalin.marinas@arm.com, james.morse@arm.com,
	luto@amacapital.net, matt@codeblueprint.co.uk,
	will.deacon@arm.com, kernel-hardening@lists.openwall.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] lkdtm: Test VMAP_STACK allocates leading/trailing guard pages
Date: Tue, 8 Aug 2017 10:23:48 +0100	[thread overview]
Message-ID: <20170808092348.GA19207@leverpostej> (raw)
In-Reply-To: <0e9a80c2-3e5e-db98-dff6-b45e9e4817fd@redhat.com>

On Mon, Aug 07, 2017 at 03:55:22PM -0700, Laura Abbott wrote:
> On 08/07/2017 03:00 PM, Mark Rutland wrote:
> > On Mon, Aug 07, 2017 at 01:39:48PM -0700, Kees Cook wrote:

> >> Do these tests both trip with the new arm64 VMAP_STACK code?
> > 
> >> +/* Test that VMAP_STACK is actually allocating with a leading guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_LEADING(void)

> >> +/* Test that VMAP_STACK is actually allocating with a trailing guard page */
> >> +void lkdtm_STACK_GUARD_PAGE_TRAILING(void)

> > I can give these a go tomorrow.
> > 
> > These *should* fault, and IIUC should trigger the usual "Unable to handle
> > kernel %s at virtual address %08lx\n" splat from arm64's __do_kernel_fault(),
> > which should end up with an Oops().

> I gave these a quick test in QEMU and they seem to do the correct thing:

> # echo STACK_GUARD_PAGE_LEADING > /sys/kernel/debug/provoke-crash/DIRECT 
> [   24.593306] lkdtm: Performing direct entry STACK_GUARD_PAGE_LEADING
> [   24.593780] lkdtm: attempting bad read from page below current stack
> [   24.594289] Unable to handle kernel paging request at virtual address ffff000009b77fff
> [   24.594747] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [   24.595443] [ffff000009b77fff] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007cc43003, *pte=0000000000000000
> [   24.596743] Internal error: Oops: 96000007 [#1] PREEMPT SMP

> # echo STACK_GUARD_PAGE_TRAILING > /sys/kernel/debug/provoke-crash/DIRECT 
> [  103.144313] lkdtm: Performing direct entry STACK_GUARD_PAGE_TRAILING
> [  103.144749] lkdtm: attempting bad read from page above current stack
> [  103.145100] Unable to handle kernel paging request at virtual address ffff000009c2c000
> [  103.145477] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff000009050000
> [  103.145836] [ffff000009c2c000] *pgd=000000007effe003, *pud=000000007effd003, *pmd=000000007d014003, *pte=0000000000000000
> [  103.146445] Internal error: Oops: 96000007 [#2] PREEMPT SMP

Great! thanks for giving those a spin.

I can confirm likewise on Juno with 64K pages (not that this should make
any difference).

Mark.

  parent reply	other threads:[~2017-08-08  9:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 20:39 [kernel-hardening] [PATCH] lkdtm: Test VMAP_STACK allocates leading/trailing guard pages Kees Cook
2017-08-07 20:39 ` Kees Cook
2017-08-07 20:39 ` Kees Cook
2017-08-07 21:27 ` [kernel-hardening] " Ard Biesheuvel
2017-08-07 21:27   ` Ard Biesheuvel
2017-08-07 21:44   ` Kees Cook
2017-08-07 21:44     ` Kees Cook
2017-08-07 21:46     ` Ard Biesheuvel
2017-08-07 21:46       ` Ard Biesheuvel
2017-08-07 21:47       ` Kees Cook
2017-08-07 21:47         ` Kees Cook
2017-08-07 22:00 ` [kernel-hardening] " Mark Rutland
2017-08-07 22:00   ` Mark Rutland
2017-08-07 22:00   ` Mark Rutland
2017-08-07 22:55   ` [kernel-hardening] " Laura Abbott
2017-08-07 22:55     ` Laura Abbott
2017-08-07 22:55     ` Laura Abbott
2017-08-07 23:34     ` [kernel-hardening] " Kees Cook
2017-08-07 23:34       ` Kees Cook
2017-08-07 23:34       ` Kees Cook
2017-08-08  9:23     ` Mark Rutland [this message]
2017-08-08  9:23       ` Mark Rutland
2017-08-08  9:23       ` Mark Rutland

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=20170808092348.GA19207@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=labbott@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=matt@codeblueprint.co.uk \
    --cc=will.deacon@arm.com \
    /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.