diff options
author | Zhang Yanfei <zhangyanfei.yes@gmail.com> | 2013-07-08 19:00:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-12 22:05:34 -0500 |
commit | 7bff7accd427da171501b558457ef8fa81ee2767 (patch) | |
tree | 958af0229e79d85eb7c30f79bc09c8b1dbc5f51f | |
parent | 18b683a2334848c003fe89e3002244ca298544f4 (diff) |
mm/vmalloc.c: fix an overflow bug in alloc_vmap_area()
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>
-rw-r--r-- | mm/vmalloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d365724feb05..d4565606cc96 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -388,12 +388,12 @@ nocache: | |||
388 | addr = ALIGN(first->va_end, align); | 388 | addr = ALIGN(first->va_end, align); |
389 | if (addr < vstart) | 389 | if (addr < vstart) |
390 | goto nocache; | 390 | goto nocache; |
391 | if (addr + size - 1 < addr) | 391 | if (addr + size < addr) |
392 | goto overflow; | 392 | goto overflow; |
393 | 393 | ||
394 | } else { | 394 | } else { |
395 | addr = ALIGN(vstart, align); | 395 | addr = ALIGN(vstart, align); |
396 | if (addr + size - 1 < addr) | 396 | if (addr + size < addr) |
397 | goto overflow; | 397 | goto overflow; |
398 | 398 | ||
399 | n = vmap_area_root.rb_node; | 399 | n = vmap_area_root.rb_node; |
@@ -420,7 +420,7 @@ nocache: | |||
420 | if (addr + cached_hole_size < first->va_start) | 420 | if (addr + cached_hole_size < first->va_start) |
421 | cached_hole_size = first->va_start - addr; | 421 | cached_hole_size = first->va_start - addr; |
422 | addr = ALIGN(first->va_end, align); | 422 | addr = ALIGN(first->va_end, align); |
423 | if (addr + size - 1 < addr) | 423 | if (addr + size < addr) |
424 | goto overflow; | 424 | goto overflow; |
425 | 425 | ||
426 | if (list_is_last(&first->list, &vmap_area_list)) | 426 | if (list_is_last(&first->list, &vmap_area_list)) |