mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-02-08 19:08:44 -05:00
17.1: switch to latest hardened_malloc revision
+ dedupe the other hmalloc patches Signed-off-by: Tavi <tavi@divested.dev>
This commit is contained in:
parent
11b5815f14
commit
321de1adbc
@ -150,7 +150,7 @@ external/grpc-grpc-java 9b4f1a6db99b7cb7d46320e25e32317853b500dc
|
|||||||
external/guava 6501bf9c8011e09d21905a4cf263d6f5625d1465
|
external/guava 6501bf9c8011e09d21905a4cf263d6f5625d1465
|
||||||
external/guice 0cb6b120e56be5ac654ef6bc0a9bf1d71905193f
|
external/guice 0cb6b120e56be5ac654ef6bc0a9bf1d71905193f
|
||||||
external/hamcrest 3d96516e09640e606da166e1dff54fb65c9a3a35
|
external/hamcrest 3d96516e09640e606da166e1dff54fb65c9a3a35
|
||||||
external/hardened_malloc 526ccd915180ae9d0464f4e92c1c485c2ec91dec
|
external/hardened_malloc 749640c274d54e084505a24fa758bcb5f96a25ef
|
||||||
external/harfbuzz_ng 5c6da22b1751b83076979c8d16f48054a7c58b19
|
external/harfbuzz_ng 5c6da22b1751b83076979c8d16f48054a7c58b19
|
||||||
external/honggfuzz b7bc4c1a1a355ba5f92bd70520eb2af461324a14
|
external/honggfuzz b7bc4c1a1a355ba5f92bd70520eb2af461324a14
|
||||||
external/hyphenation-patterns e5b0bea19621cc2467eca1d7ccbaf2b69f667862
|
external/hyphenation-patterns e5b0bea19621cc2467eca1d7ccbaf2b69f667862
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<project path="external/svox" name="platform/external/svox" groups="pdk" remote="aosp" revision="master" />
|
<project path="external/svox" name="platform/external/svox" groups="pdk" remote="aosp" revision="master" />
|
||||||
|
|
||||||
<!-- GrapheneOS -->
|
<!-- GrapheneOS -->
|
||||||
<project path="external/hardened_malloc" name="GrapheneOS/hardened_malloc" remote="github" revision="526ccd915180ae9d0464f4e92c1c485c2ec91dec" />
|
<project path="external/hardened_malloc" name="GrapheneOS/hardened_malloc" remote="github" revision="749640c274d54e084505a24fa758bcb5f96a25ef" />
|
||||||
<!-- END OF ADDITIONAL REPOS -->
|
<!-- END OF ADDITIONAL REPOS -->
|
||||||
|
|
||||||
<!-- START OF DEVICE REPOS -->
|
<!-- START OF DEVICE REPOS -->
|
||||||
|
@ -4,14 +4,14 @@ Date: Thu, 28 May 2020 20:19:14 -0400
|
|||||||
Subject: [PATCH] workaround for audio service sorting bug
|
Subject: [PATCH] workaround for audio service sorting bug
|
||||||
|
|
||||||
---
|
---
|
||||||
h_malloc.c | 15 ++++++++++++---
|
h_malloc.c | 10 +++++++++-
|
||||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
diff --git a/h_malloc.c b/h_malloc.c
|
||||||
index 8d15ab2..dbedbd4 100644
|
index 6c3b148..4090b0c 100644
|
||||||
--- a/h_malloc.c
|
--- a/h_malloc.c
|
||||||
+++ b/h_malloc.c
|
+++ b/h_malloc.c
|
||||||
@@ -85,6 +85,7 @@ static union {
|
@@ -83,6 +83,7 @@ static union {
|
||||||
bool zero_on_free;
|
bool zero_on_free;
|
||||||
bool purge_slabs;
|
bool purge_slabs;
|
||||||
bool region_quarantine_protect;
|
bool region_quarantine_protect;
|
||||||
@ -19,29 +19,16 @@ index 8d15ab2..dbedbd4 100644
|
|||||||
};
|
};
|
||||||
char padding[PAGE_SIZE];
|
char padding[PAGE_SIZE];
|
||||||
} ro __attribute__((aligned(PAGE_SIZE)));
|
} ro __attribute__((aligned(PAGE_SIZE)));
|
||||||
@@ -355,7 +356,7 @@ static u64 get_mask(size_t slots) {
|
@@ -386,7 +387,7 @@ static u64 get_mask(size_t slots) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_metadata *metadata) {
|
static size_t get_free_slot(struct random_state *rng, size_t slots, const struct slab_metadata *metadata) {
|
||||||
- if (SLOT_RANDOMIZE) {
|
- if (SLOT_RANDOMIZE) {
|
||||||
+ if (ro.slot_randomize) {
|
+ if (ro.slot_randomize) {
|
||||||
// randomize start location for linear search (uniform random choice is too slow)
|
// randomize start location for linear search (uniform random choice is too slow)
|
||||||
unsigned random_index = get_random_u16_uniform(rng, slots);
|
size_t random_index = get_random_u16_uniform(rng, slots);
|
||||||
unsigned first_bitmap = random_index / 64;
|
size_t first_bitmap = random_index / U64_WIDTH;
|
||||||
@@ -1061,17 +1062,24 @@ static inline void enforce_init(void) {
|
@@ -1218,6 +1219,12 @@ COLD static void handle_bugs(void) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-COLD static void handle_hal_bugs(void) {
|
|
||||||
+COLD static void handle_bugs(void) {
|
|
||||||
char path[256];
|
|
||||||
if (readlink("/proc/self/exe", path, sizeof(path)) == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
if (strcmp(camera_provider, path) == 0) {
|
|
||||||
ro.zero_on_free = false;
|
|
||||||
ro.purge_slabs = false;
|
ro.purge_slabs = false;
|
||||||
ro.region_quarantine_protect = false;
|
ro.region_quarantine_protect = false;
|
||||||
}
|
}
|
||||||
@ -53,14 +40,12 @@ index 8d15ab2..dbedbd4 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
COLD static void init_slow_path(void) {
|
static struct mutex init_lock = MUTEX_INITIALIZER;
|
||||||
@@ -1100,7 +1108,8 @@ COLD static void init_slow_path(void) {
|
@@ -1238,6 +1245,7 @@ COLD static void init_slow_path(void) {
|
||||||
ro.purge_slabs = true;
|
ro.purge_slabs = true;
|
||||||
ro.zero_on_free = ZERO_ON_FREE;
|
ro.zero_on_free = ZERO_ON_FREE;
|
||||||
ro.region_quarantine_protect = true;
|
ro.region_quarantine_protect = true;
|
||||||
- handle_hal_bugs();
|
|
||||||
+ ro.slot_randomize = SLOT_RANDOMIZE;
|
+ ro.slot_randomize = SLOT_RANDOMIZE;
|
||||||
+ handle_bugs();
|
handle_bugs();
|
||||||
|
|
||||||
if (sysconf(_SC_PAGESIZE) != PAGE_SIZE) {
|
if (unlikely(sysconf(_SC_PAGESIZE) != PAGE_SIZE)) {
|
||||||
fatal_error("page size mismatch");
|
|
@ -1,25 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 15 Mar 2022 22:18:26 -0400
|
|
||||||
Subject: [PATCH] Expand workaround to all camera executables
|
|
||||||
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
Change-Id: I23513ec0379bbb10829f989690334e9704fd20e2
|
|
||||||
---
|
|
||||||
h_malloc.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index dbedbd4..d0cf881 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1069,7 +1069,8 @@ COLD static void handle_bugs(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
- if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ // Any camera executable on system partition
|
|
||||||
+ if (strcmp(camera_provider, path) == 0 || (strstr(path, "camera") != NULL && (strncmp("/system", path, 7) == 0 || strncmp("/vendor", path, 7) == 0))) {
|
|
||||||
ro.zero_on_free = false;
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
@ -1,25 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 15 Mar 2022 22:18:26 -0400
|
|
||||||
Subject: [PATCH] Expand workaround to all camera executables
|
|
||||||
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
Change-Id: I23513ec0379bbb10829f989690334e9704fd20e2
|
|
||||||
---
|
|
||||||
h_malloc.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index de693c9..f680fa6 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1058,7 +1058,8 @@ COLD static void handle_bugs(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
- if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ // Any camera executable on system partition
|
|
||||||
+ if (strcmp(camera_provider, path) == 0 || (strstr(path, "camera") != NULL && (strncmp("/system", path, 7) == 0 || strncmp("/vendor", path, 7) == 0))) {
|
|
||||||
ro.zero_on_free = false;
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
File diff suppressed because it is too large
Load Diff
@ -1,102 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Micay <danielmicay@gmail.com>
|
|
||||||
Date: Tue, 1 Jan 2019 14:45:27 -0500
|
|
||||||
Subject: [PATCH] workarounds for Pixel 3 SoC era camera driver bugs
|
|
||||||
|
|
||||||
---
|
|
||||||
h_malloc.c | 33 ++++++++++++++++++++++++++++-----
|
|
||||||
1 file changed, 28 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 15be0a2..3fa9ed7 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -80,6 +80,9 @@ static union {
|
|
||||||
#ifdef MEMTAG
|
|
||||||
bool is_memtag_disabled;
|
|
||||||
#endif
|
|
||||||
+ bool zero_on_free;
|
|
||||||
+ bool purge_slabs;
|
|
||||||
+ bool region_quarantine_protect;
|
|
||||||
};
|
|
||||||
char padding[PAGE_SIZE];
|
|
||||||
} ro __attribute__((aligned(PAGE_SIZE)));
|
|
||||||
@@ -465,7 +468,7 @@ static void *slot_pointer(size_t size, void *slab, size_t slot) {
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_after_free_check(const char *p, size_t size) {
|
|
||||||
- if (!WRITE_AFTER_FREE_CHECK) {
|
|
||||||
+ if (!WRITE_AFTER_FREE_CHECK || !ro.zero_on_free) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -812,7 +815,7 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
- if (ZERO_ON_FREE && !skip_zero) {
|
|
||||||
+ if (ro.zero_on_free && !skip_zero) {
|
|
||||||
memset(p, 0, size - canary_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -890,7 +893,7 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
|
||||||
|
|
||||||
if (c->empty_slabs_total + slab_size > max_empty_slabs_total) {
|
|
||||||
int saved_errno = errno;
|
|
||||||
- if (!memory_map_fixed(slab, slab_size)) {
|
|
||||||
+ if (ro.purge_slabs && !memory_map_fixed(slab, slab_size)) {
|
|
||||||
label_slab(slab, slab_size, class);
|
|
||||||
stats_slab_deallocate(c, slab_size);
|
|
||||||
enqueue_free_slab(c, metadata);
|
|
||||||
@@ -976,7 +979,7 @@ static void regions_quarantine_deallocate_pages(void *p, size_t size, size_t gua
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (unlikely(memory_map_fixed(p, size))) {
|
|
||||||
+ if (!ro.region_quarantine_protect || unlikely(memory_map_fixed(p, size))) {
|
|
||||||
memory_purge(p, size);
|
|
||||||
} else {
|
|
||||||
memory_set_name(p, size, "malloc large quarantine");
|
|
||||||
@@ -1192,6 +1195,21 @@ static inline void enforce_init(void) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+COLD static void handle_bugs(void) {
|
|
||||||
+ char path[256];
|
|
||||||
+ if (readlink("/proc/self/exe", path, sizeof(path)) == -1) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Pixel 3, Pixel 3 XL, Pixel 3a and Pixel 3a XL camera provider
|
|
||||||
+ const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
+ if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ ro.zero_on_free = false;
|
|
||||||
+ ro.purge_slabs = false;
|
|
||||||
+ ro.region_quarantine_protect = false;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static struct mutex init_lock = MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
COLD static void init_slow_path(void) {
|
|
||||||
@@ -1207,6 +1225,11 @@ COLD static void init_slow_path(void) {
|
|
||||||
ro.metadata_pkey = pkey_alloc(0, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+ ro.purge_slabs = true;
|
|
||||||
+ ro.zero_on_free = ZERO_ON_FREE;
|
|
||||||
+ ro.region_quarantine_protect = true;
|
|
||||||
+ handle_bugs();
|
|
||||||
+
|
|
||||||
if (unlikely(sysconf(_SC_PAGESIZE) != PAGE_SIZE)) {
|
|
||||||
fatal_error("runtime page size does not match compile-time page size which is not supported");
|
|
||||||
}
|
|
||||||
@@ -1491,7 +1514,7 @@ EXPORT void *h_calloc(size_t nmemb, size_t size) {
|
|
||||||
}
|
|
||||||
total_size = adjust_size_for_canary(total_size);
|
|
||||||
void *p = alloc(total_size);
|
|
||||||
- if (!ZERO_ON_FREE && likely(p != NULL) && total_size && total_size <= max_slab_size_class) {
|
|
||||||
+ if (!ro.zero_on_free && likely(p != NULL) && total_size && total_size <= max_slab_size_class) {
|
|
||||||
memset(p, 0, total_size - canary_size);
|
|
||||||
}
|
|
||||||
#ifdef HAS_ARM_MTE
|
|
@ -1,25 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 15 Mar 2022 22:18:26 -0400
|
|
||||||
Subject: [PATCH] Expand workaround to all camera executables
|
|
||||||
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
Change-Id: I23513ec0379bbb10829f989690334e9704fd20e2
|
|
||||||
---
|
|
||||||
h_malloc.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 3fa9ed7..0308d73 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1203,7 +1203,8 @@ COLD static void handle_bugs(void) {
|
|
||||||
|
|
||||||
// Pixel 3, Pixel 3 XL, Pixel 3a and Pixel 3a XL camera provider
|
|
||||||
const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
- if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ // Any camera executable on system partition
|
|
||||||
+ if (strcmp(camera_provider, path) == 0 || (strstr(path, "camera") != NULL && (strncmp("/system", path, 7) == 0 || strncmp("/vendor", path, 7) == 0 || strncmp("/apex", path, 5) == 0))) {
|
|
||||||
ro.zero_on_free = false;
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
@ -1,31 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 22 Nov 2022 07:23:10 -0500
|
|
||||||
Subject: [PATCH] Add workaround for OnePlus 8 & 9 display driver crash
|
|
||||||
|
|
||||||
Change-Id: Ie7a0ca79bb629814e57958d57546f85030b67048
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
---
|
|
||||||
h_malloc.c | 9 +++++++++
|
|
||||||
1 file changed, 9 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 0308d73..6c3b148 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1209,6 +1209,15 @@ COLD static void handle_bugs(void) {
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // OnePlus 8 & 9 display composer
|
|
||||||
+ // https://gitlab.com/divested-mobile/divestos-build/-/issues/19
|
|
||||||
+ const char hwc[] = "/vendor/bin/hw/vendor.qti.hardware.display.composer-service";
|
|
||||||
+ if (strcmp(hwc, path) == 0) {
|
|
||||||
+ ro.zero_on_free = false;
|
|
||||||
+ ro.purge_slabs = false;
|
|
||||||
+ ro.region_quarantine_protect = false;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct mutex init_lock = MUTEX_INITIALIZER;
|
|
@ -1,102 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Micay <danielmicay@gmail.com>
|
|
||||||
Date: Tue, 1 Jan 2019 14:45:27 -0500
|
|
||||||
Subject: [PATCH] workarounds for Pixel 3 SoC era camera driver bugs
|
|
||||||
|
|
||||||
---
|
|
||||||
h_malloc.c | 33 ++++++++++++++++++++++++++++-----
|
|
||||||
1 file changed, 28 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 15be0a2..3fa9ed7 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -80,6 +80,9 @@ static union {
|
|
||||||
#ifdef MEMTAG
|
|
||||||
bool is_memtag_disabled;
|
|
||||||
#endif
|
|
||||||
+ bool zero_on_free;
|
|
||||||
+ bool purge_slabs;
|
|
||||||
+ bool region_quarantine_protect;
|
|
||||||
};
|
|
||||||
char padding[PAGE_SIZE];
|
|
||||||
} ro __attribute__((aligned(PAGE_SIZE)));
|
|
||||||
@@ -465,7 +468,7 @@ static void *slot_pointer(size_t size, void *slab, size_t slot) {
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_after_free_check(const char *p, size_t size) {
|
|
||||||
- if (!WRITE_AFTER_FREE_CHECK) {
|
|
||||||
+ if (!WRITE_AFTER_FREE_CHECK || !ro.zero_on_free) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -812,7 +815,7 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
- if (ZERO_ON_FREE && !skip_zero) {
|
|
||||||
+ if (ro.zero_on_free && !skip_zero) {
|
|
||||||
memset(p, 0, size - canary_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -890,7 +893,7 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
|
||||||
|
|
||||||
if (c->empty_slabs_total + slab_size > max_empty_slabs_total) {
|
|
||||||
int saved_errno = errno;
|
|
||||||
- if (!memory_map_fixed(slab, slab_size)) {
|
|
||||||
+ if (ro.purge_slabs && !memory_map_fixed(slab, slab_size)) {
|
|
||||||
label_slab(slab, slab_size, class);
|
|
||||||
stats_slab_deallocate(c, slab_size);
|
|
||||||
enqueue_free_slab(c, metadata);
|
|
||||||
@@ -976,7 +979,7 @@ static void regions_quarantine_deallocate_pages(void *p, size_t size, size_t gua
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (unlikely(memory_map_fixed(p, size))) {
|
|
||||||
+ if (!ro.region_quarantine_protect || unlikely(memory_map_fixed(p, size))) {
|
|
||||||
memory_purge(p, size);
|
|
||||||
} else {
|
|
||||||
memory_set_name(p, size, "malloc large quarantine");
|
|
||||||
@@ -1192,6 +1195,21 @@ static inline void enforce_init(void) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+COLD static void handle_bugs(void) {
|
|
||||||
+ char path[256];
|
|
||||||
+ if (readlink("/proc/self/exe", path, sizeof(path)) == -1) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Pixel 3, Pixel 3 XL, Pixel 3a and Pixel 3a XL camera provider
|
|
||||||
+ const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
+ if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ ro.zero_on_free = false;
|
|
||||||
+ ro.purge_slabs = false;
|
|
||||||
+ ro.region_quarantine_protect = false;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static struct mutex init_lock = MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
COLD static void init_slow_path(void) {
|
|
||||||
@@ -1207,6 +1225,11 @@ COLD static void init_slow_path(void) {
|
|
||||||
ro.metadata_pkey = pkey_alloc(0, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+ ro.purge_slabs = true;
|
|
||||||
+ ro.zero_on_free = ZERO_ON_FREE;
|
|
||||||
+ ro.region_quarantine_protect = true;
|
|
||||||
+ handle_bugs();
|
|
||||||
+
|
|
||||||
if (unlikely(sysconf(_SC_PAGESIZE) != PAGE_SIZE)) {
|
|
||||||
fatal_error("runtime page size does not match compile-time page size which is not supported");
|
|
||||||
}
|
|
||||||
@@ -1491,7 +1514,7 @@ EXPORT void *h_calloc(size_t nmemb, size_t size) {
|
|
||||||
}
|
|
||||||
total_size = adjust_size_for_canary(total_size);
|
|
||||||
void *p = alloc(total_size);
|
|
||||||
- if (!ZERO_ON_FREE && likely(p != NULL) && total_size && total_size <= max_slab_size_class) {
|
|
||||||
+ if (!ro.zero_on_free && likely(p != NULL) && total_size && total_size <= max_slab_size_class) {
|
|
||||||
memset(p, 0, total_size - canary_size);
|
|
||||||
}
|
|
||||||
#ifdef HAS_ARM_MTE
|
|
@ -1,25 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 15 Mar 2022 22:18:26 -0400
|
|
||||||
Subject: [PATCH] Expand workaround to all camera executables
|
|
||||||
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
Change-Id: I23513ec0379bbb10829f989690334e9704fd20e2
|
|
||||||
---
|
|
||||||
h_malloc.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 3fa9ed7..0308d73 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1203,7 +1203,8 @@ COLD static void handle_bugs(void) {
|
|
||||||
|
|
||||||
// Pixel 3, Pixel 3 XL, Pixel 3a and Pixel 3a XL camera provider
|
|
||||||
const char camera_provider[] = "/vendor/bin/hw/android.hardware.camera.provider@2.4-service_64";
|
|
||||||
- if (strcmp(camera_provider, path) == 0) {
|
|
||||||
+ // Any camera executable on system partition
|
|
||||||
+ if (strcmp(camera_provider, path) == 0 || (strstr(path, "camera") != NULL && (strncmp("/system", path, 7) == 0 || strncmp("/vendor", path, 7) == 0 || strncmp("/apex", path, 5) == 0))) {
|
|
||||||
ro.zero_on_free = false;
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
@ -1,31 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tad <tad@spotco.us>
|
|
||||||
Date: Tue, 22 Nov 2022 07:23:10 -0500
|
|
||||||
Subject: [PATCH] Add workaround for OnePlus 8 & 9 display driver crash
|
|
||||||
|
|
||||||
Change-Id: Ie7a0ca79bb629814e57958d57546f85030b67048
|
|
||||||
Signed-off-by: Tad <tad@spotco.us>
|
|
||||||
---
|
|
||||||
h_malloc.c | 9 +++++++++
|
|
||||||
1 file changed, 9 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/h_malloc.c b/h_malloc.c
|
|
||||||
index 0308d73..6c3b148 100644
|
|
||||||
--- a/h_malloc.c
|
|
||||||
+++ b/h_malloc.c
|
|
||||||
@@ -1209,6 +1209,15 @@ COLD static void handle_bugs(void) {
|
|
||||||
ro.purge_slabs = false;
|
|
||||||
ro.region_quarantine_protect = false;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // OnePlus 8 & 9 display composer
|
|
||||||
+ // https://gitlab.com/divested-mobile/divestos-build/-/issues/19
|
|
||||||
+ const char hwc[] = "/vendor/bin/hw/vendor.qti.hardware.display.composer-service";
|
|
||||||
+ if (strcmp(hwc, path) == 0) {
|
|
||||||
+ ro.zero_on_free = false;
|
|
||||||
+ ro.purge_slabs = false;
|
|
||||||
+ ro.region_quarantine_protect = false;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct mutex init_lock = MUTEX_INITIALIZER;
|
|
@ -120,8 +120,8 @@ fi;
|
|||||||
#if [ "$DOS_GRAPHENE_MALLOC_BROKEN" = true ]; then
|
#if [ "$DOS_GRAPHENE_MALLOC_BROKEN" = true ]; then
|
||||||
#if enterAndClear "external/hardened_malloc"; then
|
#if enterAndClear "external/hardened_malloc"; then
|
||||||
#git revert --no-edit 3d18fb80742fd80a75481b580d102deb18c74af9; #compile fix
|
#git revert --no-edit 3d18fb80742fd80a75481b580d102deb18c74af9; #compile fix
|
||||||
#applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc/0001-Broken_Audio.patch"; #DeviceDescriptor sorting wrongly relies on malloc addresses (GrapheneOS)
|
#applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-legacy/0001-Broken_Audio.patch"; #DeviceDescriptor sorting wrongly relies on malloc addresses (GrapheneOS)
|
||||||
#applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc/0002-Broken_Cameras.patch"; #Expand workaround to all camera executables (DivestOS)
|
#applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-legacy/0002-Broken_Cameras.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
#sed -i 's/struct mallinfo info = {0};/struct mallinfo info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/' h_malloc.c; #compile fix
|
#sed -i 's/struct mallinfo info = {0};/struct mallinfo info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/' h_malloc.c; #compile fix
|
||||||
#fi;
|
#fi;
|
||||||
#fi;
|
#fi;
|
||||||
|
@ -140,8 +140,8 @@ fi;
|
|||||||
|
|
||||||
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
||||||
if enterAndClear "external/hardened_malloc"; then
|
if enterAndClear "external/hardened_malloc"; then
|
||||||
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc/0001-Broken_Audio.patch"; #DeviceDescriptor sorting wrongly relies on malloc addresses (GrapheneOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-legacy/0001-Broken_Audio.patch"; #DeviceDescriptor sorting wrongly relies on malloc addresses (GrapheneOS)
|
||||||
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc/0002-Broken_Cameras.patch"; #Expand workaround to all camera executables (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-legacy/0002-Broken_Cameras.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
@ -122,7 +122,19 @@ fi;
|
|||||||
|
|
||||||
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
||||||
if enterAndClear "external/hardened_malloc"; then
|
if enterAndClear "external/hardened_malloc"; then
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras.patch"; #Expand workaround to all camera executables (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
||||||
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
||||||
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0003-Broken_Audio.patch"; #Workaround for audio service sorting bug (GrapheneOS)
|
||||||
|
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
||||||
|
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
||||||
|
sed -i -e '22,24d;' androidtest/Android.bp; #fix compile under A12
|
||||||
|
awk -i inplace '!/vendor_ramdisk_available/' Android.bp; #fix compile under A11
|
||||||
|
rm -rfv androidtest;
|
||||||
|
sed -i -e '76,78d;' Android.bp; #fix compile under A10
|
||||||
|
awk -i inplace '!/ramdisk_available/' Android.bp;
|
||||||
|
git revert --no-edit 8974af86d12f7e29b54b5090133ab3d7eea0e519;
|
||||||
|
mv include/h_malloc.h .
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
@ -593,6 +605,7 @@ enableLowRam "device/wileyfox/crackling" "crackling";
|
|||||||
|
|
||||||
sed -i 's/^YYLTYPE yylloc;/extern YYLTYPE yylloc;/' kernel/*/*/scripts/dtc/dtc-lexer.l* || true; #Fix builds with GCC 10
|
sed -i 's/^YYLTYPE yylloc;/extern YYLTYPE yylloc;/' kernel/*/*/scripts/dtc/dtc-lexer.l* || true; #Fix builds with GCC 10
|
||||||
rm -v kernel/*/*/drivers/staging/greybus/tools/Android.mk || true;
|
rm -v kernel/*/*/drivers/staging/greybus/tools/Android.mk || true;
|
||||||
|
sed -i '117ioutputEntry.setCompressedSize(-1);' external/jarjar/src/main/com/tonicsystems/jarjar/util/IoUtil.java; #Fix compile error
|
||||||
#
|
#
|
||||||
#END OF DEVICE CHANGES
|
#END OF DEVICE CHANGES
|
||||||
#
|
#
|
||||||
|
@ -120,9 +120,9 @@ fi;
|
|||||||
|
|
||||||
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
||||||
if enterAndClear "external/hardened_malloc"; then
|
if enterAndClear "external/hardened_malloc"; then
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
||||||
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
||||||
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
||||||
sed -i -e '22,24d;' androidtest/Android.bp; #fix compile under A12
|
sed -i -e '22,24d;' androidtest/Android.bp; #fix compile under A12
|
||||||
|
@ -117,9 +117,9 @@ fi;
|
|||||||
|
|
||||||
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
||||||
if enterAndClear "external/hardened_malloc"; then
|
if enterAndClear "external/hardened_malloc"; then
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
||||||
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
||||||
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
||||||
sed -i -e '22,24d;' androidtest/Android.bp; #fix compile under A12
|
sed -i -e '22,24d;' androidtest/Android.bp; #fix compile under A12
|
||||||
|
@ -116,9 +116,9 @@ fi;
|
|||||||
|
|
||||||
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then
|
||||||
if enterAndClear "external/hardened_malloc"; then
|
if enterAndClear "external/hardened_malloc"; then
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-1.patch"; #Workarounds for Pixel 3 SoC era camera driver bugs (GrapheneOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0001-Broken_Cameras-2.patch"; #Expand workaround to all camera executables (DivestOS)
|
||||||
applyPatch "$DOS_PATCHES/android_external_hardened_malloc/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
applyPatch "$DOS_PATCHES_COMMON/android_external_hardened_malloc-modern/0002-Broken_Displays.patch"; #Add workaround for OnePlus 8 & 9 display driver crash (DivestOS)
|
||||||
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
sed -i 's/34359738368/2147483648/' Android.bp; #revert 48-bit address space requirement
|
||||||
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
sed -i -e '76,78d;' Android.bp; #fix compile under A13
|
||||||
fi;
|
fi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user