OSDN Git Service

Fix vulnerability in MemoryIntArray
authorSvetoslav Ganov <svetoslavganov@google.com>
Thu, 8 Dec 2016 19:48:19 +0000 (11:48 -0800)
committerSvetoslav Ganov <svetoslavganov@google.com>
Thu, 8 Dec 2016 19:51:26 +0000 (11:51 -0800)
commita97171ec499fd876722733f35e51d0d6dbd8d223
tree9974ef5c3642cd9b1a4b62f0603728f5705f569e
parent1f06508bc640b90e613179f6371f53b9a839fa53
Fix vulnerability in MemoryIntArray

MemoryIntArray was using the size of the undelying
ashmem region to mmap the data but the ashmem size
can be changed until the former is memory mapped.
Since we use the ashmem region size for boundary
checking and memory unmapping if it does not match
the size used while mapping an attacker can force
the system to unmap memory or to access undefined
memory and crash.

Also we were passing the memory address where the
ashmem region is mapped in the owner process to
support cases where the client can pass back the
MemoryIntArray instance. This allows an attacker
to put invalid address and cause arbitrary memory
to be freed.

Now we no longer support passing back the instance
to the owner process (the passed back instance is
read only), so no need to pass the memory adress
of the owner's mapping, thus not allowing freeing
arbitrary memory.

 Further, we now check the memory mapped size against
 the size of the underlying ashmem region after we do
 the memory mapping (to fix the ahsmem size) and if
 an attacker changed the size under us we throw.

 Tests: Updated the tests and they pass.

 bug:33039926
 bug:33042690

Change-Id: I1004579181ff7a223ef659e85c46100c47ab2409
core/java/android/util/MemoryIntArray.java
core/jni/android_util_MemoryIntArray.cpp
core/tests/utiltests/Android.mk
core/tests/utiltests/jni/Android.mk [new file with mode: 0644]
core/tests/utiltests/jni/android_util_MemoryIntArrayTest.cpp [new file with mode: 0644]
core/tests/utiltests/jni/registration.cpp [new file with mode: 0644]
core/tests/utiltests/src/android/util/IRemoteMemoryIntArray.aidl
core/tests/utiltests/src/android/util/MemoryIntArrayTest.java
core/tests/utiltests/src/android/util/RemoteIntArray.java
core/tests/utiltests/src/android/util/RemoteMemoryIntArrayService.java
packages/SettingsProvider/src/com/android/providers/settings/GenerationRegistry.java