mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-05-31 04:04:16 -04: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
23 changed files with 1104 additions and 1475 deletions
|
@ -1,66 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Micay <danielmicay@gmail.com>
|
||||
Date: Thu, 28 May 2020 20:19:14 -0400
|
||||
Subject: [PATCH] workaround for audio service sorting bug
|
||||
|
||||
---
|
||||
h_malloc.c | 15 ++++++++++++---
|
||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/h_malloc.c b/h_malloc.c
|
||||
index 8d15ab2..dbedbd4 100644
|
||||
--- a/h_malloc.c
|
||||
+++ b/h_malloc.c
|
||||
@@ -85,6 +85,7 @@ static union {
|
||||
bool zero_on_free;
|
||||
bool purge_slabs;
|
||||
bool region_quarantine_protect;
|
||||
+ bool slot_randomize;
|
||||
};
|
||||
char padding[PAGE_SIZE];
|
||||
} ro __attribute__((aligned(PAGE_SIZE)));
|
||||
@@ -355,7 +356,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) {
|
||||
- if (SLOT_RANDOMIZE) {
|
||||
+ if (ro.slot_randomize) {
|
||||
// randomize start location for linear search (uniform random choice is too slow)
|
||||
unsigned random_index = get_random_u16_uniform(rng, slots);
|
||||
unsigned first_bitmap = random_index / 64;
|
||||
@@ -1061,17 +1062,24 @@ static inline void enforce_init(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.region_quarantine_protect = false;
|
||||
}
|
||||
+
|
||||
+ // DeviceDescriptor sorting wrongly relies on malloc addresses
|
||||
+ const char audio_service[] = "/system/bin/audioserver";
|
||||
+ if (strcmp(audio_service, path) == 0) {
|
||||
+ ro.slot_randomize = false;
|
||||
+ }
|
||||
}
|
||||
|
||||
COLD static void init_slow_path(void) {
|
||||
@@ -1100,7 +1108,8 @@ COLD static void init_slow_path(void) {
|
||||
ro.purge_slabs = true;
|
||||
ro.zero_on_free = ZERO_ON_FREE;
|
||||
ro.region_quarantine_protect = true;
|
||||
- handle_hal_bugs();
|
||||
+ ro.slot_randomize = SLOT_RANDOMIZE;
|
||||
+ handle_bugs();
|
||||
|
||||
if (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;
|
Loading…
Add table
Add a link
Reference in a new issue