[lkml]   [2019]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] mm/z3fold: Fix z3fold_buddy_slots use after free
Hi Henry,

On Mon, Jul 1, 2019 at 8:31 PM Henry Burns <> wrote:
> Running z3fold stress testing with address sanitization
> showed zhdr->slots was being used after it was freed.
> z3fold_free(z3fold_pool, handle)
> free_handle(handle)
> kmem_cache_free(pool->c_handle, zhdr->slots)
> release_z3fold_page_locked_list(kref)
> __release_z3fold_page(zhdr, true)
> zhdr_to_pool(zhdr)
> slots_to_pool(zhdr->slots) *BOOM*

Thanks for looking into this. I'm not entirely sure I'm all for
splitting free_handle() but let me think about it.

> Instead we split free_handle into two functions, release_handle()
> and free_slots(). We use release_handle() in place of free_handle(),
> and use free_slots() to call kmem_cache_free() after
> __release_z3fold_page() is done.

A little less intrusive solution would be to move backlink to pool
from slots back to z3fold_header. Looks like it was a bad idea from
the start.

Best regards,

 \ /
  Last update: 2019-07-02 09:47    [W:0.096 / U:3.928 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site