From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Tue, 2 May 2023 16:47:49 +0300 Subject: [PATCH] disable hardened_malloc for Pixel camera provider service --- libc/bionic/libc_init_dynamic.cpp | 3 +++ libc/bionic/malloc_common.cpp | 3 +++ libc/include/stdlib.h | 1 + 3 files changed, 7 insertions(+) diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp index 804e586e2..7097a70b0 100644 --- a/libc/bionic/libc_init_dynamic.cpp +++ b/libc/bionic/libc_init_dynamic.cpp @@ -84,6 +84,9 @@ static void init_prog_id(libc_globals* globals) { #define IS(prog) (!strcmp(exe_path, prog)) + if (IS("/apex/com.google.pixel.camera.hal/bin/hw/android.hardware.camera.provider@2.7-service-google")) { + prog_id = PROG_PIXEL_CAMERA_PROVIDER_SERVICE; + } #undef IS // libc_globals struct is write-protected diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp index 3d3e8ef61..9b7310347 100644 --- a/libc/bionic/malloc_common.cpp +++ b/libc/bionic/malloc_common.cpp @@ -425,6 +425,9 @@ static const MallocDispatch* native_allocator_dispatch; void InitNativeAllocatorDispatch(libc_globals* globals) { bool hardened_impl = true; switch (get_prog_id()) { + case PROG_PIXEL_CAMERA_PROVIDER_SERVICE: + hardened_impl = false; + break; default: hardened_impl = getenv("DISABLE_HARDENED_MALLOC") == nullptr; } diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 5ce8f9103..cb8d3d3b2 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -213,6 +213,7 @@ long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, i int get_prog_id(); #define is_prog(id) (get_prog_id() == id) +#define PROG_PIXEL_CAMERA_PROVIDER_SERVICE 1 __END_DECLS #include