linux-sg2042/ipc
Lee Schermerhorn 69682d852f mempolicy: fix reference counting bugs
Address 3 known bugs in the current memory policy reference counting method.
I have a series of patches to rework the reference counting to reduce overhead
in the allocation path.  However, that series will require testing in -mm once
I repost it.

1) alloc_page_vma() does not release the extra reference taken for
   vma/shared mempolicy when the mode == MPOL_INTERLEAVE.  This can result in
   leaking mempolicy structures.  This is probably occurring, but not being
   noticed.

   Fix:  add the conditional release of the reference.

2) hugezonelist unconditionally releases a reference on the mempolicy when
   mode == MPOL_INTERLEAVE.  This can result in decrementing the reference
   count for system default policy [should have no ill effect] or premature
   freeing of task policy.  If this occurred, the next allocation using task
   mempolicy would use the freed structure and probably BUG out.

   Fix:  add the necessary check to the release.

3) The current reference counting method assumes that vma 'get_policy()'
   methods automatically add an extra reference a non-NULL returned mempolicy.
    This is true for shmem_get_policy() used by tmpfs mappings, including
   regular page shm segments.  However, SHM_HUGETLB shm's, backed by
   hugetlbfs, just use the vma policy without the extra reference.  This
   results in freeing of the vma policy on the first allocation, with reuse of
   the freed mempolicy structure on subsequent allocations.

   Fix: Rather than add another condition to the conditional reference
   release, which occur in the allocation path, just add a reference when
   returning the vma policy in shm_get_policy() to match the assumptions.

Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Greg KH <greg@kroah.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: David Rientjes <rientjes@google.com>
Cc: <eric.whitney@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-03-10 18:01:19 -07:00
..
Makefile namespaces: move the IPC namespace under IPC_NS option 2008-02-08 09:22:23 -08:00
compat.c fix logic error in ipc compat semctl() 2007-07-06 10:23:43 -07:00
compat_mq.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipc_sysctl.c namespaces: move the IPC namespace under IPC_NS option 2008-02-08 09:22:23 -08:00
mqueue.c Pidns: fix badly converted mqueues pid handling 2008-02-08 09:22:29 -08:00
msg.c IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns() 2008-02-08 09:22:26 -08:00
msgutil.c [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
namespace.c IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns() 2008-02-08 09:22:26 -08:00
sem.c IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns() 2008-02-08 09:22:26 -08:00
shm.c mempolicy: fix reference counting bugs 2008-03-10 18:01:19 -07:00
util.c IPC: make struct ipc_ids static in ipc_namespace 2008-02-08 09:22:26 -08:00
util.h IPC: make struct ipc_ids static in ipc_namespace 2008-02-08 09:22:26 -08:00