Sync up to v203

This commit is contained in:
Andy CrossGate Yan 2019-11-11 08:05:40 +00:00
parent c621f4bcdc
commit cf227232bc
3 changed files with 32 additions and 87 deletions

View File

@ -1,54 +0,0 @@
From 38b21e5ba3f2ee5c8a6473ed20e6fa1946bdd2e3 Mon Sep 17 00:00:00 2001
From: Ethan Chen <intervigil@gmail.com>
Date: Tue, 25 Sep 2018 00:11:05 -0700
Subject: [PATCH 2/6] Actually restore pre-P mutex behavior
Apps built against versions < P may not actually expect the EBUSY return
code, and may crash or otherwise misbehave. Check for target SDK
versions earlier than P when performing the IsMutexDestroyed check so
any invocation of HandleUsingDestroyedMutex is bypassed and pre-P mutex
behavior is restored.
See 9e989f12d1186231d97dac6d038db7955acebdf3 for the change that
introduced this new behavior.
Change-Id: I45f8882c9527c63eed1ef5820a5004b8958d58ea
---
libc/bionic/pthread_mutex.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index f92184e50..f006bb92d 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -783,16 +783,23 @@ static int MutexLockWithTimeout(pthread_mutex_internal_t* mutex, bool use_realti
} // namespace NonPI
static inline __always_inline bool IsMutexDestroyed(uint16_t mutex_state) {
- return mutex_state == 0xffff;
+ if (android_get_application_target_sdk_version() >= __ANDROID_API_P__) {
+ return mutex_state == 0xffff;
+ }
+ return false;
}
// Inlining this function in pthread_mutex_lock() adds the cost of stack frame instructions on
// ARM64. So make it noinline.
static int __attribute__((noinline)) HandleUsingDestroyedMutex(pthread_mutex_t* mutex,
const char* function_name) {
- if (android_get_application_target_sdk_version() >= __ANDROID_API_P__) {
- __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
- }
+ __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
+ return EBUSY;
+}
+
+static int __always_inline HandleUsingDestroyedMutex(pthread_mutex_t* mutex,
+ const char* function_name) {
+ __fortify_fatal("%s called on a destroyed mutex (%p)", function_name, mutex);
return EBUSY;
}
--
2.17.1

View File

@ -1,33 +0,0 @@
From 45eed08a80644561adc9e103e7d58af691afeb86 Mon Sep 17 00:00:00 2001
From: nx111 <gd.zhangdz@gmail.com>
Date: Wed, 3 Oct 2018 16:58:19 +0800
Subject: [PATCH 3/6] bionic: Use legacy pthread_mutex_init() behavior on pre-P
API levels
* Google's changes to pthread_mutex_init is breaking RIL
on certain Samsung devices like klte and hlte
* To resolve this, add a check for their new additions
to only apply the new behavior for P and higher APIs
Change-Id: I41335c5c436fa28a66d044e6634466556dfd7f95
---
libc/bionic/pthread_mutex.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index f006bb92d..969feb43c 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -527,7 +527,8 @@ int pthread_mutex_init(pthread_mutex_t* mutex_interface, const pthread_mutexattr
return EINVAL;
}
- if (((*attr & MUTEXATTR_PROTOCOL_MASK) >> MUTEXATTR_PROTOCOL_SHIFT) == PTHREAD_PRIO_INHERIT) {
+ if (((*attr & MUTEXATTR_PROTOCOL_MASK) >> MUTEXATTR_PROTOCOL_SHIFT) == PTHREAD_PRIO_INHERIT
+ && bionic_get_application_target_sdk_version() >= __ANDROID_API_P__) {
#if !defined(__LP64__)
if (state & MUTEX_SHARED_MASK) {
return EINVAL;
--
2.17.1

View File

@ -0,0 +1,32 @@
From ef7918d80d3dcd9341e8bc967a1215e687ff5d47 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 1 Nov 2019 18:22:13 +0100
Subject: [PATCH 14/14] Ugly but secure: Set /dev/uinput as 0666 to fix
fingerprint sensor on some devices
cf https://github.com/phhusson/device_phh_treble/pull/122/commits/e000d69c286b6686777ea6f1867f379e30273e48
This is safe because even though it's 0666, its SELinux policy is very
tight, and only bluetooth HAL, shell (and fingerprint HAL on Xiaomi) can
access it.
Change-Id: Id374e781957927d5604cb96c7a39b3fb28b3a6c5
---
rootdir/ueventd.rc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index 451f5adf3..41ad5bd09 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -45,7 +45,7 @@ subsystem sound
# these should not be world writable
/dev/uhid 0660 uhid uhid
-/dev/uinput 0660 uhid uhid
+/dev/uinput 0666 uhid uhid
/dev/rtc0 0640 system system
/dev/tty0 0660 root system
/dev/graphics/* 0660 root graphics
--
2.17.1