lkml.org 
[lkml]   [2019]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4/5] kasan, slub: move kasan_poison_slab hook before page_address
    Date
    With tag based KASAN page_address() looks at the page flags to see
    whether the resulting pointer needs to have a tag set. Since we don't
    want to set a tag when page_address() is called on SLAB pages, we call
    page_kasan_tag_reset() in kasan_poison_slab(). However in allocate_slab()
    page_address() is called before kasan_poison_slab(). Fix it by changing
    the order.

    Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
    ---
    mm/slub.c | 9 ++++++---
    1 file changed, 6 insertions(+), 3 deletions(-)

    diff --git a/mm/slub.c b/mm/slub.c
    index 4a3d7686902f..ce874a5c9ee7 100644
    --- a/mm/slub.c
    +++ b/mm/slub.c
    @@ -1642,12 +1642,15 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
    if (page_is_pfmemalloc(page))
    SetPageSlabPfmemalloc(page);

    + kasan_poison_slab(page);
    +
    start = page_address(page);

    - if (unlikely(s->flags & SLAB_POISON))
    + if (unlikely(s->flags & SLAB_POISON)) {
    + metadata_access_enable();
    memset(start, POISON_INUSE, PAGE_SIZE << order);
    -
    - kasan_poison_slab(page);
    + metadata_access_disable();
    + }

    shuffle = shuffle_freelist(s, page);

    --
    2.20.1.791.gb4d0f1c61a-goog
    \
     
     \ /
      Last update: 2019-02-11 23:00    [W:2.758 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site