<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/staging/android, branch v4.4.171</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.4.171</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.4.171'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2018-10-10T06:52:06+00:00</updated>
<entry>
<title>staging: android: ashmem: Fix mmap size validation</title>
<updated>2018-10-10T06:52:06+00:00</updated>
<author>
<name>Alistair Strachan</name>
<email>astrachan@google.com</email>
</author>
<published>2018-06-20T00:57:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=778ebfa4c973f0960825bab52da019687d530236'/>
<id>urn:sha1:778ebfa4c973f0960825bab52da019687d530236</id>
<content type='text'>
[ Upstream commit 8632c614565d0c5fdde527889601c018e97b6384 ]

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos &lt;tkjos@android.com&gt;
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: Joel Fernandes &lt;joel@joelfernandes.org&gt;
Signed-off-by: Alistair Strachan &lt;astrachan@google.com&gt;
Acked-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Reviewed-by: Martijn Coenen &lt;maco@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free</title>
<updated>2018-09-15T07:40:37+00:00</updated>
<author>
<name>Greg Hackmann</name>
<email>ghackmann@android.com</email>
</author>
<published>2018-09-04T16:33:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2c155709e4ef2d86d0176aac82e44c048a7e0255'/>
<id>urn:sha1:2c155709e4ef2d86d0176aac82e44c048a7e0255</id>
<content type='text'>
The ION_IOC_{MAP,SHARE} ioctls drop and reacquire client-&gt;lock several
times while operating on one of the client's ion_handles.  This creates
windows where userspace can call ION_IOC_FREE on the same client with
the same handle, and effectively make the kernel drop its own reference.
For example:

- thread A: ION_IOC_ALLOC creates an ion_handle with refcount 1
- thread A: starts ION_IOC_MAP and increments the refcount to 2
- thread B: ION_IOC_FREE decrements the refcount to 1
- thread B: ION_IOC_FREE decrements the refcount to 0 and frees the
            handle
- thread A: continues ION_IOC_MAP with a dangling ion_handle * to
            freed memory

Fix this by holding client-&gt;lock for the duration of
ION_IOC_{MAP,SHARE}, preventing the concurrent ION_IOC_FREE.  Also
remove ion_handle_get_by_id(), since there's literally no way to use it
safely.

This patch is applied on top of 4.4.y, and applies to older kernels
too.  4.9.y was fixed separately.  Kernels 4.12 and later are
unaffected, since all the underlying ion_handle infrastructure has been
ripped out.

Cc: stable@vger.kernel.org # v4.4-
Signed-off-by: Greg Hackmann &lt;ghackmann@google.com&gt;
Acked-by: Laura Abbott &lt;labbott@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>staging: android: ion: check for kref overflow</title>
<updated>2018-08-24T11:27:00+00:00</updated>
<author>
<name>Daniel Rosenberg</name>
<email>drosen@google.com</email>
</author>
<published>2018-08-21T20:31:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b84ec04bae905901f5226a67968dabc52ab0c3a6'/>
<id>urn:sha1:b84ec04bae905901f5226a67968dabc52ab0c3a6</id>
<content type='text'>
This patch is against 4.4. It does not apply to master due to a large
rework of ion in 4.12 which removed the affected functions altogther.
4c23cbff073f3b9b ("staging: android: ion: Remove import interface")

Userspace can cause the kref to handles to increment
arbitrarily high. Ensure it does not overflow.

Signed-off-by: Daniel Rosenberg &lt;drosen@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>staging: android: ion: Return an ERR_PTR in ion_map_kernel</title>
<updated>2018-07-11T14:03:47+00:00</updated>
<author>
<name>Laura Abbott</name>
<email>labbott@redhat.com</email>
</author>
<published>2018-06-11T18:06:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=58fcaeb30e27df934c3cd5f13733292d2b455fa0'/>
<id>urn:sha1:58fcaeb30e27df934c3cd5f13733292d2b455fa0</id>
<content type='text'>
commit 0a2bc00341dcfcc793c0dbf4f8d43adf60458b05 upstream.

The expected return value from ion_map_kernel is an ERR_PTR. The error
path for a vmalloc failure currently just returns NULL, triggering
a warning in ion_buffer_kmap_get. Encode the vmalloc failure as an ERR_PTR.

Reported-by: syzbot+55b1d9f811650de944c6@syzkaller.appspotmail.com
Signed-off-by: Laura Abbott &lt;labbott@redhat.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging: ion : Donnot wakeup kswapd in ion system alloc</title>
<updated>2018-04-29T05:50:01+00:00</updated>
<author>
<name>Chen Feng</name>
<email>puck.chen@hisilicon.com</email>
</author>
<published>2016-01-15T02:38:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e1df9302a2f43b29312d0f6ccbde52f7211eca97'/>
<id>urn:sha1:e1df9302a2f43b29312d0f6ccbde52f7211eca97</id>
<content type='text'>
commit 2ef230531ee171a475fc3ddad5516dd7e09a8a77 upstream.

Since ion alloc can be called by userspace,eg gralloc.
When it is called frequently, the efficiency of kswapd is
to low. And the reclaimed memory is too lower. In this way,
the kswapd can use to much cpu resources.

With 3.5GB DMA Zone and 0.5 Normal Zone.

pgsteal_kswapd_dma 9364140
pgsteal_kswapd_normal 7071043
pgscan_kswapd_dma 10428250
pgscan_kswapd_normal 37840094

With this change the reclaim ratio has greatly improved
18.9% -&gt; 72.5%

Signed-off-by: Chen Feng &lt;puck.chen@hisilicon.com&gt;
Signed-off-by: Lu bing &lt;albert.lubing@hisilicon.com&gt;
Reviewed-by: Laura Abbott &lt;labbott@redhat.com&gt;
Cc: Greg Hackmann &lt;ghackmann@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging: android: ashmem: Fix possible deadlock in ashmem_ioctl</title>
<updated>2018-03-24T09:58:40+00:00</updated>
<author>
<name>Yisheng Xie</name>
<email>xieyisheng1@huawei.com</email>
</author>
<published>2018-02-28T06:59:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=603879959893f807290ec8c1c08cd21da8fe37bd'/>
<id>urn:sha1:603879959893f807290ec8c1c08cd21da8fe37bd</id>
<content type='text'>
commit 740a5759bf222332fbb5eda42f89aa25ba38f9b2 upstream.

ashmem_mutex may create a chain of dependencies like:

CPU0                                    CPU1
 mmap syscall                           ioctl syscall
 -&gt; mmap_sem (acquired)                 -&gt; ashmem_ioctl
 -&gt; ashmem_mmap                            -&gt; ashmem_mutex (acquired)
    -&gt; ashmem_mutex (try to acquire)       -&gt; copy_from_user
                                              -&gt; 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

Fixes: ce8a3a9e76d0 (staging: android: ashmem: Fix a race condition in pin ioctls)
Reported-by: syzbot+d7a918a7a8e1c952bc36@syzkaller.appspotmail.com
Signed-off-by: Yisheng Xie &lt;xieyisheng1@huawei.com&gt;
Cc: "Joel Fernandes (Google)" &lt;joel.opensrc@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging: android: ashmem: Fix lockdep issue during llseek</title>
<updated>2018-03-18T10:17:53+00:00</updated>
<author>
<name>Joel Fernandes</name>
<email>joelaf@google.com</email>
</author>
<published>2018-02-16T19:02:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e29c324dd91e38dd262e09d33fda93b0dbccaf90'/>
<id>urn:sha1:e29c324dd91e38dd262e09d33fda93b0dbccaf90</id>
<content type='text'>
commit cb57469c9573f6018cd1302953dd45d6e05aba7b upstream.

ashmem_mutex create a chain of dependencies like so:

(1)
mmap syscall -&gt;
  mmap_sem -&gt;  (acquired)
  ashmem_mmap
  ashmem_mutex (try to acquire)
  (block)

(2)
llseek syscall -&gt;
  ashmem_llseek -&gt;
  ashmem_mutex -&gt;  (acquired)
  inode_lock -&gt;
  inode-&gt;i_rwsem (try to acquire)
  (block)

(3)
getdents -&gt;
  iterate_dir -&gt;
  inode_lock -&gt;
  inode-&gt;i_rwsem   (acquired)
  copy_to_user -&gt;
  mmap_sem         (try to acquire)

There is a lock ordering created between mmap_sem and inode-&gt;i_rwsem
causing a lockdep splat [2] during a syzcaller test, this patch fixes
the issue by unlocking the mutex earlier. Functionally that's Ok since
we don't need to protect vfs_llseek.

[1] https://patchwork.kernel.org/patch/10185031/
[2] https://lkml.org/lkml/2018/1/10/48

Acked-by: Todd Kjos &lt;tkjos@google.com&gt;
Cc: Arve Hjonnevag &lt;arve@android.com&gt;
Cc: stable@vger.kernel.org
Reported-by: syzbot+8ec30bb7bf1a981a2012@syzkaller.appspotmail.com
Signed-off-by: Joel Fernandes &lt;joelaf@google.com&gt;
Acked-by: Greg Hackmann &lt;ghackmann@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging: android: ashmem: Fix a race condition in pin ioctls</title>
<updated>2018-02-25T10:03:38+00:00</updated>
<author>
<name>Ben Hutchings</name>
<email>ben@decadent.org.uk</email>
</author>
<published>2018-02-04T02:06:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=74d1cc277e8bdb3d6ee6e12a989ba059e8be9431'/>
<id>urn:sha1:74d1cc277e8bdb3d6ee6e12a989ba059e8be9431</id>
<content type='text'>
commit ce8a3a9e76d0193e2e8d74a06d275b3c324ca652 upstream.

ashmem_pin_unpin() reads asma-&gt;file and asma-&gt;size before taking the
ashmem_mutex, so it can race with other operations that modify them.

Build-tested only.

Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl</title>
<updated>2018-01-17T08:35:32+00:00</updated>
<author>
<name>Viktor Slavkovic</name>
<email>viktors@google.com</email>
</author>
<published>2018-01-08T18:43:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b4106c55b574fe37900b02ddf89cbe4b9d971392'/>
<id>urn:sha1:b4106c55b574fe37900b02ddf89cbe4b9d971392</id>
<content type='text'>
commit 443064cb0b1fb4569fe0a71209da7625129fb760 upstream.

A lock-unlock is missing in ASHMEM_SET_SIZE ioctl which can result in a
race condition when mmap is called. After the !asma-&gt;file check, before
setting asma-&gt;size, asma-&gt;file can be set in mmap. That would result in
having different asma-&gt;size than the mapped memory size. Combined with
ASHMEM_UNPIN ioctl and shrinker invocation, this can result in memory
corruption.

Signed-off-by: Viktor Slavkovic &lt;viktors@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>staging/android/ion : fix a race condition in the ion driver</title>
<updated>2017-04-30T03:49:29+00:00</updated>
<author>
<name>EunTaik Lee</name>
<email>eun.taik.lee@samsung.com</email>
</author>
<published>2016-02-24T04:38:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a7544fdd1626b65db635022c9d36007bb32dd6d8'/>
<id>urn:sha1:a7544fdd1626b65db635022c9d36007bb32dd6d8</id>
<content type='text'>
commit 9590232bb4f4cc824f3425a6e1349afbe6d6d2b7 upstream.

There is a use-after-free problem in the ion driver.
This is caused by a race condition in the ion_ioctl()
function.

A handle has ref count of 1 and two tasks on different
cpus calls ION_IOC_FREE simultaneously.

cpu 0                                   cpu 1
-------------------------------------------------------
ion_handle_get_by_id()
(ref == 2)
                            ion_handle_get_by_id()
                            (ref == 3)

ion_free()
(ref == 2)

ion_handle_put()
(ref == 1)

                            ion_free()
                            (ref == 0 so ion_handle_destroy() is
                            called
                            and the handle is freed.)

                            ion_handle_put() is called and it
                            decreases the slub's next free pointer

The problem is detected as an unaligned access in the
spin lock functions since it uses load exclusive
 instruction. In some cases it corrupts the slub's
free pointer which causes a mis-aligned access to the
next free pointer.(kmalloc returns a pointer like
ffffc0745b4580aa). And it causes lots of other
hard-to-debug problems.

This symptom is caused since the first member in the
ion_handle structure is the reference count and the
ion driver decrements the reference after it has been
freed.

To fix this problem client-&gt;lock mutex is extended
to protect all the codes that uses the handle.

Signed-off-by: Eun Taik Lee &lt;eun.taik.lee@samsung.com&gt;
Reviewed-by: Laura Abbott &lt;labbott@redhat.com&gt;
Cc: Ben Hutchings &lt;ben.hutchings@codethink.co.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

index 7ff2a7ec871f..33b390e7ea31
</content>
</entry>
</feed>
