Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1687380

Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP
Date 2017-07-14 15:00 +0200
Message-ID <u38mn-3Ag-45@gated-at.bofh.it> (permalink)
References (6 earlier) <u2Qz7-fX-9@gated-at.bofh.it> <u2R29-FW-21@gated-at.bofh.it> <u36aS-28v-15@gated-at.bofh.it> <u36kx-2cw-3@gated-at.bofh.it> <u38mm-3Ag-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 14 July 2017 at 13:52, Mark Rutland <mark.rutland@arm.com> wrote:
> On Fri, Jul 14, 2017 at 11:48:20AM +0100, Ard Biesheuvel wrote:
>> On 14 July 2017 at 11:32, Mark Rutland <mark.rutland@arm.com> wrote:
>> > On Thu, Jul 13, 2017 at 07:28:48PM +0100, Ard Biesheuvel wrote:
>> >> On 13 July 2017 at 18:55, Mark Rutland <mark.rutland@arm.com> wrote:
>> >> > On Thu, Jul 13, 2017 at 05:10:50PM +0100, Mark Rutland wrote:
>> >> >> On Thu, Jul 13, 2017 at 12:49:48PM +0100, Ard Biesheuvel wrote:
>> >> >> > On 13 July 2017 at 11:49, Mark Rutland <mark.rutland@arm.com> wrote:
>> >> >> > > On Thu, Jul 13, 2017 at 07:58:50AM +0100, Ard Biesheuvel wrote:
>> >> >> > >> On 12 July 2017 at 23:33, Mark Rutland <mark.rutland@arm.com> wrote:
>> > This means that we have to align the initial task, so the kernel Image
>> > will grow by THREAD_SIZE. Likewise for IRQ stacks, unless we can rework
>> > things such that we can dynamically allocate all of those.
>> >
>>
>> We can't currently do that for 64k pages, since the segment alignment
>> is only 64k. But we should be able to patch that up I think
>
> I was assuming that the linked would bump up the segment alignment if a
> more-aligned object were placed inside. I guess that doesn't happen in
> all cases?
>
> ... or do you mean when the EFI stub relocates the kernel, assuming
> relaxed alignment constraints?
>

No, I mean under KASLR, which randomizes at SEGMENT_ALIGN granularity.

>> >> >> I believe that determining whether the exception was caused by a stack
>> >> >> overflow is not something we can do robustly or efficiently.
>> >>
>> >> Actually, if the stack pointer is within S_FRAME_SIZE of the base, and
>> >> the faulting address points into the guard page, that is a pretty
>> >> strong indicator that the stack overflowed. That shouldn't be too
>> >> costly?
>> >
>> > Sure, but that's still a a heuristic. For example, that also catches an
>> > unrelated vmalloc address gone wrong, while SP was close to the end of
>> > the stack.
>>
>> Yes, but the likelihood that an unrelated stray vmalloc access is
>> within 16 KB of a stack pointer that is close ot its limit is
>> extremely low, so we should be able to live with the risk of
>> misidentifying it.
>
> I guess, but at that point, why bother?
>
> That gives us a fuzzy check for one specific "stack overflow", while not
> catching the general case.
>
> So long as we have a reliable stack trace, we can figure out that was
> the case, and we don't set the expectation that we're trying to
> categorize the general case (minefield and all).
>

Yes. As long as the context is described accurately, there is no need
to make any inferences on behalf of the user.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 0/6] arm64: alternative VMAP_STACK implementation Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
  [RFC PATCH 5/6] arm64: keep track of current stack Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
  [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
    Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-13 09:00 +0200
      Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-13 13:00 +0200
        Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-13 13:50 +0200
          Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-13 18:20 +0200
            Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-13 20:00 +0200
              Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-13 20:30 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-14 12:40 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 12:50 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 14:30 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-14 16:10 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 16:20 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Robin Murphy <robin.murphy@arm.com> - 2017-07-14 16:40 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Robin Murphy <robin.murphy@arm.com> - 2017-07-14 17:10 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 17:20 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-14 17:30 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-14 23:30 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-16 02:10 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Mark Rutland <mark.rutland@arm.com> - 2017-07-14 15:00 +0200
                Re: [kernel-hardening] Re: [RFC PATCH 6/6] arm64: add VMAP_STACK and  detect out-of-bounds SP Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 15:00 +0200
  [RFC PATCH 4/6] arm64: pass stack base to secondary_start_kernel Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
  [RFC PATCH 1/6] arm64: use tpidr_el1 for current, free sp_el0 Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
    Re: [RFC PATCH 1/6] arm64: use tpidr_el1 for current, free sp_el0 Will Deacon <will.deacon@arm.com> - 2017-07-14 03:40 +0200
  [RFC PATCH 3/6] arm64: pad stacks to PAGE_SIZE for VMAP_STACK Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
  [RFC PATCH 2/6] arm64: avoid open-coding THREAD_SIZE{,_ORDER} Mark Rutland <mark.rutland@arm.com> - 2017-07-13 00:40 +0200
    Re: [RFC PATCH 2/6] arm64: avoid open-coding THREAD_SIZE{,_ORDER} James Morse <james.morse@arm.com> - 2017-07-13 12:20 +0200
      Re: [RFC PATCH 2/6] arm64: avoid open-coding THREAD_SIZE{,_ORDER} Mark Rutland <mark.rutland@arm.com> - 2017-07-13 13:30 +0200

csiph-web