Commit graph

7 commits

Author SHA1 Message Date
me-cafebabe
ac25b3eb52 compat: libc: Convert to Android.bp
While we're at it:
* Rename to libc_*_shim
* Move the source files to /libc/

Change-Id: I7eb08ae8ab7ff5349814d4475ab08fcfc95e8854
2023-09-25 16:58:50 +00:00
Nich
ca8a75680f compat: libc: Add pthread_mutex_destroy hack for camera
In Pie, Google added checks to prevent destroying of the same mutexes
consecutively, and aborts the program on fortify fatal call.

Our camera blobs trigger this check when tearing down an ISP session,
destroying the same mutex consecutively by adding a destroy instruction
in a loop. This causes the whole daemon to crash and fail.

(Specifically, the violating instructions were from isp_module_stop_session
and when isp_module_start_session fails to create a thread.)

Workaround the issue by shimming the function; catching destroyed
mutexes and returning -EBUSY without passing on the bad mutexes to libc.

Change-Id: I4f8542a496dc25c53f8208a647cc0d6acc8662eb
2023-09-25 16:58:50 +00:00
Nich
ae85aa2b64 compat: libc: Trim down pthread_cond_timedwait hack
Change-Id: Ie53c8358dd0fd3d05c56353d3b388467d082241c
2023-09-25 16:58:50 +00:00
Nich
5c6ed67f4e compat: libc: compile shim with GCC again..
Change-Id: Ib4f5f8874919554493b67a3467aee8a32daf5486
2023-09-25 16:58:50 +00:00
Nich
53e071b8d3 compat: libc: Specific naming of libc shim library
* The shim is only used for converting timespecs, rename the shim lib
   to suggest such.
 * Build it with Clang since it doesn't break anything.

Change-Id: I8cfed10b73655f9aa1f4780dffc5106347441c3e
2023-09-25 16:58:50 +00:00
Nich
33327b651f compat: libc: Bring libc hax inline with the latest sources
-> [1] added tests to ensure nano timespecs are below 1000000000
-> Legacy blobs before N were able to use tv_nsec > 100000000
-> One such example would be our libmmcamera2_sensor_modules.so, which
have instances of timeouts of 5000000000 nsecs.
-> The previous workaround was to shim the old libc functions to
skip these tests, but that was really ugly since we leave out bug fixes
and security patches introduced from MM up till Oreo.
-> Current workaround is applied on the latest bionic code by correcting
the invalid timespecs, taking out each second from tv_nsec, and then
adding them to tv_sec, until tv_nsec goes below 1 second.
-> Due to bionic's tight security, we've got no choice but to copy-paste
its functions here.

[1]: https://android.googlesource.com/platform/bionic/+/c9a659c

Change-Id: I271f2899db54a252d0d2a018cf4eb7877b97a02a
2023-09-25 16:58:50 +00:00
Arne Coucheron
3825e72a3c compat: libc: Transition to OSS libc shim
Change-Id: I607a6016bb3e290713b0faa10c6ee2f875d61158
2023-09-25 16:58:50 +00:00