On Tue, Mar 20, 2018 at 1:44 AM, Anthony Yznaga <anthony.yznaga@xxxxxxxxxx> wrote: > Hi Andrey, > > On 3/2/18 11:44 AM, Andrey Konovalov wrote: >> void kasan_poison_kfree(void *ptr, unsigned long ip) >> { >> + struct page *page; >> + >> + page = virt_to_head_page(ptr) > > An untagged addr should be passed to virt_to_head_page(), no? Hi! virt_to_head_page() relies on virt_to_phys(), and the latter will be fixed to accept tagged pointers in the next patchset. Thanks! > >> + >> + if (unlikely(!PageSlab(page))) { >> + if (reset_tag(ptr) != page_address(page)) { >> + /* Report invalid-free here */ >> + return; >> + } >> + kasan_poison_shadow(ptr, PAGE_SIZE << compound_order(page), >> + khwasan_random_tag()); >> + } else { >> + __kasan_slab_free(page->slab_cache, ptr, ip); >> + } >> } >> >> void kasan_kfree_large(void *ptr, unsigned long ip) >> { >> + struct page *page = virt_to_page(ptr); >> + struct page *head_page = virt_to_head_page(ptr); > > Same as above and for virt_to_page() as well. > > Anthony > > >> + >> + if (reset_tag(ptr) != page_address(head_page)) { >> + /* Report invalid-free here */ >> + return; >> + } >> + >> + kasan_poison_shadow(ptr, PAGE_SIZE << compound_order(page), >> + khwasan_random_tag()); >> }