lkml.org 
[lkml]   [2021]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 21/31] kasan, fork: don't tag stacks allocated with vmalloc
    Date
    From: Andrey Konovalov <andreyknvl@google.com>

    Once tag-based KASAN modes start tagging vmalloc() allocations,
    kernel stacks will start getting tagged if CONFIG_VMAP_STACK is enabled.

    Reset the tag of kernel stack pointers after allocation.

    For SW_TAGS KASAN, when CONFIG_KASAN_STACK is enabled, the
    instrumentation can't handle the sp register being tagged.

    For HW_TAGS KASAN, there's no instrumentation-related issues. However,
    the impact of having a tagged SP pointer needs to be properly evaluated,
    so keep it non-tagged for now.

    Note, that the memory for the stack allocation still gets tagged to
    catch vmalloc-into-stack out-of-bounds accesses.

    Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
    ---
    kernel/fork.c | 1 +
    1 file changed, 1 insertion(+)

    diff --git a/kernel/fork.c b/kernel/fork.c
    index 3244cc56b697..062d1484ef42 100644
    --- a/kernel/fork.c
    +++ b/kernel/fork.c
    @@ -253,6 +253,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
    * so cache the vm_struct.
    */
    if (stack) {
    + stack = kasan_reset_tag(stack);
    tsk->stack_vm_area = find_vm_area(stack);
    tsk->stack = stack;
    }
    --
    2.25.1
    \
     
     \ /
      Last update: 2021-11-30 23:08    [W:4.054 / U:0.632 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site