[PATCH 3/4] arm64/kasan: don't allocate extra shadow memory
From: dvyukov@google.com (Dmitry Vyukov)
Date: 2017-06-01 17:06:18
Also in:
linux-mm, lkml
On Thu, Jun 1, 2017 at 7:00 PM, Andrey Ryabinin [off-list ref] wrote:
On 06/01/2017 07:59 PM, Andrey Ryabinin wrote:quoted
On 06/01/2017 07:52 PM, Mark Rutland wrote:quoted
On Thu, Jun 01, 2017 at 06:45:32PM +0200, Dmitry Vyukov wrote:quoted
On Thu, Jun 1, 2017 at 6:34 PM, Mark Rutland [off-list ref] wrote:quoted
On Thu, Jun 01, 2017 at 07:23:37PM +0300, Andrey Ryabinin wrote:quoted
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.quoted
quoted
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-accessess/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)?