On Thu, Mar 13, 2025 at 3:58 PM Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx> wrote: > > >So this was my brain converting things to assembly. Feel free to > >reword/clarify the comments. > > Right, I focused too much on the signed aspect. Treating everything as > overflowing sounds better, more unified. Alright! > >It could be that your checks are equivalent to mine. What I did was to > >check that the address lies outside of both contiguous regions, which > >makes the checks symmetrical and IMO easier to follow. > > I drew this out and yeah, it looks like it's the same, just grouping the logical > expressions differently. What do you think about incorporating something like > the following into your comment about the x86 part? : > > Given the KASAN_SHADOW_OFFSET equal 0xffeffc0000000000 > the following ranges are valid mem-to-shadow mappings: > > 0xFFFFFFFFFFFFFFFF > INVALID > 0xFFEFFBFFFFFFFFFF - kasan_mem_to_shadow(~0UL) > VALID - kasan shadow mem > VALID - non-canonical kernel virtual address > 0xFFCFFC0000000000 - kasan_mem_to_shadow(0xFEUL << 56) > INVALID > 0x07EFFBFFFFFFFFFF - kasan_mem_to_shadow(~0UL >> 1) > VALID - non-canonical user virtual addresses > VALID - user addresses > 0x07CFFC0000000000 - kasan_mem_to_shadow(0x7EUL << 56) > INVALID > 0x0000000000000000 Sounds good - I like this visual representation a lot! Thanks!