staging: ashmem: Avoid deadlock between read and mmap calls
authorTodd Poynor <toddpoynor@google.com>
Wed, 5 Feb 2014 00:08:37 +0000 (16:08 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Feb 2014 17:03:16 +0000 (09:03 -0800)
commit077f6db9731673753ca41a5c3acbb5ead142658a
tree4846028c95f948bd89be3437e9005af5e2c668e3
parent5cf045f54d31894ec59ee741e01fa258be2ba0fb
staging: ashmem: Avoid deadlock between read and mmap calls

Avoid holding ashmem_mutex across code that can page fault.  Page faults
grab the mmap_sem for the process, which are also held by mmap calls
prior to calling ashmem_mmap, which locks ashmem_mutex.  The reversed
order of locking between the two can deadlock.

The calls that can page fault are read() and the ASHMEM_SET_NAME and
ASHMEM_GET_NAME ioctls.  Move the code that accesses userspace pages
outside the ashmem_mutex.

Cc: Colin Cross <ccross@android.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
[jstultz: minor commit message tweaks]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ashmem.c