lkml.org 
[lkml]   [2013]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3.10 64/74] mm/vmalloc.c: fix an overflow bug in alloc_vmap_area()
    Date
    3.10-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Zhang Yanfei <zhangyanfei.yes@gmail.com>

    commit bcb615a81b1765864c71c50afb56631e7a1e5283 upstream.

    When searching a vmap area in the vmalloc space, we use (addr + size -
    1) to check if the value is less than addr, which is an overflow. But
    we assign (addr + size) to vmap_area->va_end.

    So if we come across the below case:

    (addr + size - 1) : not overflow
    (addr + size) : overflow

    we will assign an overflow value (e.g 0) to vmap_area->va_end, And this
    will trigger BUG in __insert_vmap_area, causing system panic.

    So using (addr + size) to check the overflow should be the correct
    behaviour, not (addr + size - 1).

    Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
    Reported-by: Ghennadi Procopciuc <unix140@gmail.com>
    Tested-by: Daniel Baluta <dbaluta@ixiacom.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Anatoly Muliarski <x86ever@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    mm/vmalloc.c | 6 +++---
    1 file changed, 3 insertions(+), 3 deletions(-)

    --- a/mm/vmalloc.c
    +++ b/mm/vmalloc.c
    @@ -388,12 +388,12 @@ nocache:
    addr = ALIGN(first->va_end, align);
    if (addr < vstart)
    goto nocache;
    - if (addr + size - 1 < addr)
    + if (addr + size < addr)
    goto overflow;

    } else {
    addr = ALIGN(vstart, align);
    - if (addr + size - 1 < addr)
    + if (addr + size < addr)
    goto overflow;

    n = vmap_area_root.rb_node;
    @@ -420,7 +420,7 @@ nocache:
    if (addr + cached_hole_size < first->va_start)
    cached_hole_size = first->va_start - addr;
    addr = ALIGN(first->va_end, align);
    - if (addr + size - 1 < addr)
    + if (addr + size < addr)
    goto overflow;

    if (list_is_last(&first->list, &vmap_area_list))



    \
     
     \ /
      Last update: 2013-11-09 08:41    [W:4.113 / U:0.376 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site