]> Git Repo - linux.git/commit
mm: avoid null pointer access in vm_struct via /proc/vmallocinfo
authorMitsuo Hayasaka <[email protected]>
Tue, 1 Nov 2011 00:08:13 +0000 (17:08 -0700)
committerLinus Torvalds <[email protected]>
Tue, 1 Nov 2011 00:30:47 +0000 (17:30 -0700)
commitf5252e009d5b87071a919221e4f6624184005368
tree4be380e99c468dcb10597c445eb6b801897eafea
parent8c5fb8eadde41f67c61a7ac2d3246dab87bf7020
mm: avoid null pointer access in vm_struct via /proc/vmallocinfo

The /proc/vmallocinfo shows information about vmalloc allocations in
vmlist that is a linklist of vm_struct.  It, however, may access pages
field of vm_struct where a page was not allocated.  This results in a null
pointer access and leads to a kernel panic.

Why this happens: In __vmalloc_node_range() called from vmalloc(), newly
allocated vm_struct is added to vmlist at __get_vm_area_node() and then,
some fields of vm_struct such as nr_pages and pages are set at
__vmalloc_area_node().  In other words, it is added to vmlist before it is
fully initialized.  At the same time, when the /proc/vmallocinfo is read,
it accesses the pages field of vm_struct according to the nr_pages field
at show_numa_info().  Thus, a null pointer access happens.

The patch adds the newly allocated vm_struct to the vmlist *after* it is
fully initialized.  So, it can avoid accessing the pages field with
unallocated page when show_numa_info() is called.

Signed-off-by: Mitsuo Hayasaka <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: Jeremy Fitzhardinge <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/vmalloc.h
mm/vmalloc.c
This page took 0.053903 seconds and 4 git commands to generate.