DivestOS/Patches/LineageOS-15.1/android_frameworks_av/0001-HM-No_RLIMIT_AS.patch
Tad a53062ca0b Backports
Adds ptrace_scope and timeout options to 17.1, tested working

Also adds hardened_malloc to 15.1, but failing to compile:
external/hardened_malloc/h_malloc.c:1688:18: error: use of undeclared identifier 'M_PURGE'
    if (param == M_PURGE) {
                 ^
external/hardened_malloc/h_malloc.c:1743:30: error: missing field 'ordblks' initializer [-Werror,-Wmissing-field-initializers]
    struct mallinfo info = {0};
                             ^

Signed-off-by: Tad <tad@spotco.us>
2022-03-21 18:06:49 -04:00

34 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Wed, 5 Dec 2018 09:29:25 -0500
Subject: [PATCH] avoid setting RLIMIT_AS with hardened malloc
This needs to be ported to a better mechanism like memory control groups
in order to remain compatible with hardening mechanisms based on large
PROT_NONE address space reservations.
Change-Id: Ibfb7164d764fcb9244055953bedc9a1c424cedcb
---
media/libmedia/MediaUtils.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/media/libmedia/MediaUtils.cpp b/media/libmedia/MediaUtils.cpp
index bcdc3bdcfe..de217c70bf 100644
--- a/media/libmedia/MediaUtils.cpp
+++ b/media/libmedia/MediaUtils.cpp
@@ -38,6 +38,14 @@ void limitProcessMemory(
return;
}
+#ifdef __LP64__
+ // This needs to be ported to a better mechanism like memory control groups
+ // in order to remain compatible with hardening mechanisms based on large
+ // PROT_NONE address space reservations.
+ ALOGW("Running with hardened malloc implementation, skip enforcing memory limitations.");
+ return;
+#endif
+
long pageSize = sysconf(_SC_PAGESIZE);
long numPages = sysconf(_SC_PHYS_PAGES);
size_t maxMem = SIZE_MAX;