staging: android: ashmem: Avoid range_alloc() allocation with ashmem_mutex held.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fri, 22 Feb 2019 11:03:55 +0000 (20:03 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Mar 2019 06:08:58 +0000 (07:08 +0100)
commitb592247edd6ba2498cf4948b61913632443ab782
treee9aa55c0e5a91c0073912cae0a17a0bb522bc6fb
parent6a6b0c1b4731bde4d28e73f7a0eb9d6ddcc84724
staging: android: ashmem: Avoid range_alloc() allocation with ashmem_mutex held.

commit ecd182cbf4e107928077866399100228d2359c60 upstream.

ashmem_pin() is calling range_shrink() without checking whether
range_alloc() succeeded. Also, doing memory allocation with ashmem_mutex
held should be avoided because ashmem_shrink_scan() tries to hold it.

Therefore, move memory allocation for range_alloc() to ashmem_pin_unpin()
and make range_alloc() not to fail.

This patch is mostly meant for backporting purpose for fuzz testing on
stable/distributor kernels, for there is a plan to remove this code in
near future.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: stable@vger.kernel.org
Reviewed-by: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ashmem.c