Patch "staging: android: ashmem: Fix possible deadlock in ashmem_ioctl" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
staging: android: ashmem: Fix possible deadlock in ashmem_ioctl
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
staging-android-ashmem-fix-possible-deadlock-in-ashmem_ioctl.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
740a5759bf222332fbb5eda42f89aa25ba38f9b2Mon Sep 17 00:00:00 2001
From: Yisheng Xie <[email protected]>
Date: Wed, 28 Feb 2018 14:59:22 +0800
Subject: staging: android: ashmem: Fix possible deadlock in ashmem_ioctl
From: Yisheng Xie <[email protected]>
commit 740a5759bf222332fbb5eda42f89aa25ba38f9b2 upstream.
ashmem_mutex may create a chain of dependencies like:
CPU0 CPU1
mmap syscall ioctl syscall
-> mmap_sem (acquired) -> ashmem_ioctl
-> ashmem_mmap -> ashmem_mutex (acquired)
-> ashmem_mutex (try to acquire) -> copy_from_user
-> mmap_sem (try to acquire)There is a lock odering problem between mmap_sem and ashmem_mutex causing a lockdep splat[1] during a syzcaller test. This patch fixes the problem by move copy_from_user out of ashmem_mutex.
[1] https://www.spinics.net/lists/kernel/msg2733200.html
--- drivers/staging/android/ashmem.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/android/ashmem.c +3 -5
@@ -718,16 +718,14 @@ static int ashmem_pin_unpin(struct ashmesize_t pgstart, pgend;int ret = -EINVAL ; +if (unlikely (copy_from_user (&pin, p,sizeof (pin)))) +return -EFAULT ; +mutex_lock (&ashmem_mutex);if (unlikely (!asma->file)) goto out_unlock; -if (unlikely (copy_from_user (&pin, p,sizeof (pin)))) { - ret = -EFAULT ; - goto out_unlock; - } -/* per custom, you can pass zero for len to mean "everything onward" */ if (!pin.len) pin.len =PAGE_ALIGN (asma->size) - pin.offset;
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/staging-android-ashmem-fix-possible-deadlock-in-ashmem_ioctl.patch