On Mon, Feb 11, 2019 at 12:31:43PM +0100, Eric Botcazou wrote: > > So, wouldn't it be better to check for STRICT_ALIGNMENT > > get_pointer_alignment (base_addr) and do this only if that alignment > > (shifted right by ASAN_SHADOW_SHIFT) is not sufficient and e.g. if we would > > know that the shadow is at least 2 byte aligned but not 4 byte aligned, use > > size = 2 instead of always 1? E.g. compute this before the loop as > > max_size and for !STRICT_ALIGNMENT use always max_size 4? > > In practice this makes a difference only for objects aligned on 128-bit or
No. 64-bit aligned offsets too. If you know 64-bit alignment of base_addr, you can use size 2 stores (though not size 4 stores) on the !STRICT_ALIGNMENT targets. And that is something still pretty common. > above boundaries though. Moreover, don't you need to take into account the > offset as well, which can be modified through -fasan-shadow-offset? No. If people use a bogus shadow offset, prologues/epilogues will not work either on strict aligned targets, and -fasan-shadow-offset is for -fsanitize=kernel-address only. Only page aligned offsets are something that is supported/reasonable. Jakub