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


Groups > linux.kernel > #1655619

Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory

From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory
Date 2017-06-01 19:40 +0200
Message-ID <tNCeK-5B8-23@gated-at.bofh.it> (permalink)
References (3 earlier) <tNBsl-53m-15@gated-at.bofh.it> <tNBC3-58o-61@gated-at.bofh.it> <tNBLJ-5r9-53@gated-at.bofh.it> <tNBLJ-5r9-55@gated-at.bofh.it> <tNBLJ-5r9-51@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Jun 1, 2017 at 7:05 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
>>>>>>> We used to read several bytes of the shadow memory in advance.
>>>>>>> Therefore additional shadow memory mapped to prevent crash if
>>>>>>> speculative load would happen near the end of the mapped shadow memory.
>>>>>>>
>>>>>>> Now we don't have such speculative loads, so we no longer need to map
>>>>>>> additional shadow memory.
>>>>>>
>>>>>> I see that patch 1 fixed up the Linux helpers for outline
>>>>>> instrumentation.
>>>>>>
>>>>>> Just to check, is it also true that the inline instrumentation never
>>>>>> performs unaligned accesses to the shadow memory?
>>>>>
>>>
>>> Correct, inline instrumentation assumes that all accesses are properly aligned as it
>>> required by C standard. I knew that the kernel violates this rule in many places,
>>> therefore I decided to add checks for unaligned accesses in outline case.
>>>
>>>
>>>>> Inline instrumentation generally accesses only a single byte.
>>>>
>>>> Sorry to be a little pedantic, but does that mean we'll never access the
>>>> additional shadow, or does that mean it's very unlikely that we will?
>>>>
>>>> I'm guessing/hoping it's the former!
>>>>
>>>
>>> Outline will never access additional shadow byte: https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm#unaligned-accesses
>>
>> s/Outline/inline  of course.
>
>
> I suspect that actual implementations have diverged from that
> description. Trying to follow asan_expand_check_ifn in:
> https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/asan.c?revision=246703&view=markup
> but it's not trivial.
>
> +Yuri, maybe you know off the top of your head if asan instrumentation
> in gcc ever accesses off-by-one shadow byte (i.e. 1 byte after actual
> object end)?

Thinking of this more. There is at least 1 case in user-space asan
where off-by-one shadow access would lead to similar crashes: for
mmap-ed regions we don't have redzones and map shadow only for the
region itself, so any off-by-one access would lead to crashes. So I
guess we are safe here. Or at least any crash would be gcc bug.

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


Thread

Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory Dmitry Vyukov <dvyukov@google.com> - 2017-06-01 18:50 +0200
  Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory Mark Rutland <mark.rutland@arm.com> - 2017-06-01 19:00 +0200
    Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory Dmitry Vyukov <dvyukov@google.com> - 2017-06-01 19:10 +0200
      Re: [PATCH 3/4] arm64/kasan: don't allocate extra shadow memory Dmitry Vyukov <dvyukov@google.com> - 2017-06-01 19:40 +0200

csiph-web