Loading media/libmedia/Android.bp +11 −0 Original line number Original line Diff line number Diff line cc_defaults { name: "libmedia_defaults", include_dirs: [ "bionic/libc/private", ], } cc_library_headers { cc_library_headers { name: "libmedia_headers", name: "libmedia_headers", vendor_available: true, vendor_available: true, Loading Loading @@ -148,6 +155,8 @@ filegroup { cc_library { cc_library { name: "libmedia", name: "libmedia", defaults: [ "libmedia_defaults" ], srcs: [ srcs: [ ":mediaupdateservice_aidl", ":mediaupdateservice_aidl", "IDataSource.cpp", "IDataSource.cpp", Loading Loading @@ -256,6 +265,8 @@ cc_library { cc_library { cc_library { name: "libmedia_player2_util", name: "libmedia_player2_util", defaults: [ "libmedia_defaults" ], srcs: [ srcs: [ "BufferingSettings.cpp", "BufferingSettings.cpp", "DataSourceDesc.cpp", "DataSourceDesc.cpp", Loading media/libmedia/MediaUtils.cpp +9 −37 Original line number Original line Diff line number Diff line Loading @@ -22,23 +22,16 @@ #include <sys/resource.h> #include <sys/resource.h> #include <unistd.h> #include <unistd.h> #include <bionic_malloc.h> #include "MediaUtils.h" #include "MediaUtils.h" extern "C" size_t __cfi_shadow_size(); extern "C" void __scudo_set_rss_limit(size_t, int) __attribute__((weak)); extern "C" void __scudo_set_rss_limit(size_t, int) __attribute__((weak)); namespace android { namespace android { void limitProcessMemory( void limitProcessMemory(const char *property, size_t numberOfBytes, const char *property, size_t numberOfBytes, size_t percentageOfTotalMem) { size_t percentageOfTotalMem) { if (running_with_asan()) { ALOGW("Running with (HW)ASan, skip enforcing memory limitations."); return; } long pageSize = sysconf(_SC_PAGESIZE); long pageSize = sysconf(_SC_PAGESIZE); long numPages = sysconf(_SC_PHYS_PAGES); long numPages = sysconf(_SC_PHYS_PAGES); size_t maxMem = SIZE_MAX; size_t maxMem = SIZE_MAX; Loading Loading @@ -66,38 +59,17 @@ void limitProcessMemory( maxMem = propVal; maxMem = propVal; } } // If 64-bit Scudo is in use, enforce the hard RSS limit (in MB). // If Scudo is in use, enforce the hard RSS limit (in MB). if (maxMem != SIZE_MAX && sizeof(void *) == 8 && if (maxMem != SIZE_MAX && &__scudo_set_rss_limit != 0) { &__scudo_set_rss_limit != 0) { __scudo_set_rss_limit(maxMem >> 20, 1); __scudo_set_rss_limit(maxMem >> 20, 1); ALOGV("Scudo hard RSS limit set to %zu MB", maxMem >> 20); ALOGV("Scudo hard RSS limit set to %zu MB", maxMem >> 20); return; return; } } // Increase by the size of the CFI shadow mapping. Most of the shadow is not if (!android_mallopt(M_SET_ALLOCATION_LIMIT_BYTES, &maxMem, // backed with physical pages, and it is possible for the result to be sizeof(maxMem))) { // higher than total physical memory. This is fine for RLIMIT_AS. ALOGW("couldn't set allocation limit"); size_t cfi_size = __cfi_shadow_size(); if (cfi_size) { ALOGV("cfi shadow size: %zu", cfi_size); if (maxMem <= SIZE_MAX - cfi_size) { maxMem += cfi_size; } else { maxMem = SIZE_MAX; } } } ALOGV("actual limit: %zu", maxMem); struct rlimit limit; getrlimit(RLIMIT_AS, &limit); ALOGV("original limits: %lld/%lld", (long long)limit.rlim_cur, (long long)limit.rlim_max); limit.rlim_cur = maxMem; setrlimit(RLIMIT_AS, &limit); limit.rlim_cur = -1; limit.rlim_max = -1; getrlimit(RLIMIT_AS, &limit); ALOGV("new limits: %lld/%lld", (long long)limit.rlim_cur, (long long)limit.rlim_max); } } } // namespace android } // namespace android media/libmedia/MediaUtils.h +0 −7 Original line number Original line Diff line number Diff line Loading @@ -19,13 +19,6 @@ namespace android { namespace android { extern "C" void __asan_init(void) __attribute__((weak)); extern "C" void __hwasan_init(void) __attribute__((weak)); static inline int running_with_asan() { return &__asan_init != 0 || &__hwasan_init != 0; } /** /** Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS). Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS). The value to use will be read from the specified system property, or if the The value to use will be read from the specified system property, or if the Loading services/mediaextractor/seccomp_policy/mediaextractor-arm.policy +1 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ getuid32: 1 setpriority: 1 setpriority: 1 sigaltstack: 1 sigaltstack: 1 openat: 1 openat: 1 open: 1 clone: 1 clone: 1 read: 1 read: 1 clock_gettime: 1 clock_gettime: 1 Loading services/mediaextractor/seccomp_policy/mediaextractor-x86.policy +1 −0 Original line number Original line Diff line number Diff line Loading @@ -11,6 +11,7 @@ munmap: 1 mmap2: 1 mmap2: 1 madvise: 1 madvise: 1 openat: 1 openat: 1 open: 1 clock_gettime: 1 clock_gettime: 1 writev: 1 writev: 1 brk: 1 brk: 1 Loading Loading
media/libmedia/Android.bp +11 −0 Original line number Original line Diff line number Diff line cc_defaults { name: "libmedia_defaults", include_dirs: [ "bionic/libc/private", ], } cc_library_headers { cc_library_headers { name: "libmedia_headers", name: "libmedia_headers", vendor_available: true, vendor_available: true, Loading Loading @@ -148,6 +155,8 @@ filegroup { cc_library { cc_library { name: "libmedia", name: "libmedia", defaults: [ "libmedia_defaults" ], srcs: [ srcs: [ ":mediaupdateservice_aidl", ":mediaupdateservice_aidl", "IDataSource.cpp", "IDataSource.cpp", Loading Loading @@ -256,6 +265,8 @@ cc_library { cc_library { cc_library { name: "libmedia_player2_util", name: "libmedia_player2_util", defaults: [ "libmedia_defaults" ], srcs: [ srcs: [ "BufferingSettings.cpp", "BufferingSettings.cpp", "DataSourceDesc.cpp", "DataSourceDesc.cpp", Loading
media/libmedia/MediaUtils.cpp +9 −37 Original line number Original line Diff line number Diff line Loading @@ -22,23 +22,16 @@ #include <sys/resource.h> #include <sys/resource.h> #include <unistd.h> #include <unistd.h> #include <bionic_malloc.h> #include "MediaUtils.h" #include "MediaUtils.h" extern "C" size_t __cfi_shadow_size(); extern "C" void __scudo_set_rss_limit(size_t, int) __attribute__((weak)); extern "C" void __scudo_set_rss_limit(size_t, int) __attribute__((weak)); namespace android { namespace android { void limitProcessMemory( void limitProcessMemory(const char *property, size_t numberOfBytes, const char *property, size_t numberOfBytes, size_t percentageOfTotalMem) { size_t percentageOfTotalMem) { if (running_with_asan()) { ALOGW("Running with (HW)ASan, skip enforcing memory limitations."); return; } long pageSize = sysconf(_SC_PAGESIZE); long pageSize = sysconf(_SC_PAGESIZE); long numPages = sysconf(_SC_PHYS_PAGES); long numPages = sysconf(_SC_PHYS_PAGES); size_t maxMem = SIZE_MAX; size_t maxMem = SIZE_MAX; Loading Loading @@ -66,38 +59,17 @@ void limitProcessMemory( maxMem = propVal; maxMem = propVal; } } // If 64-bit Scudo is in use, enforce the hard RSS limit (in MB). // If Scudo is in use, enforce the hard RSS limit (in MB). if (maxMem != SIZE_MAX && sizeof(void *) == 8 && if (maxMem != SIZE_MAX && &__scudo_set_rss_limit != 0) { &__scudo_set_rss_limit != 0) { __scudo_set_rss_limit(maxMem >> 20, 1); __scudo_set_rss_limit(maxMem >> 20, 1); ALOGV("Scudo hard RSS limit set to %zu MB", maxMem >> 20); ALOGV("Scudo hard RSS limit set to %zu MB", maxMem >> 20); return; return; } } // Increase by the size of the CFI shadow mapping. Most of the shadow is not if (!android_mallopt(M_SET_ALLOCATION_LIMIT_BYTES, &maxMem, // backed with physical pages, and it is possible for the result to be sizeof(maxMem))) { // higher than total physical memory. This is fine for RLIMIT_AS. ALOGW("couldn't set allocation limit"); size_t cfi_size = __cfi_shadow_size(); if (cfi_size) { ALOGV("cfi shadow size: %zu", cfi_size); if (maxMem <= SIZE_MAX - cfi_size) { maxMem += cfi_size; } else { maxMem = SIZE_MAX; } } } ALOGV("actual limit: %zu", maxMem); struct rlimit limit; getrlimit(RLIMIT_AS, &limit); ALOGV("original limits: %lld/%lld", (long long)limit.rlim_cur, (long long)limit.rlim_max); limit.rlim_cur = maxMem; setrlimit(RLIMIT_AS, &limit); limit.rlim_cur = -1; limit.rlim_max = -1; getrlimit(RLIMIT_AS, &limit); ALOGV("new limits: %lld/%lld", (long long)limit.rlim_cur, (long long)limit.rlim_max); } } } // namespace android } // namespace android
media/libmedia/MediaUtils.h +0 −7 Original line number Original line Diff line number Diff line Loading @@ -19,13 +19,6 @@ namespace android { namespace android { extern "C" void __asan_init(void) __attribute__((weak)); extern "C" void __hwasan_init(void) __attribute__((weak)); static inline int running_with_asan() { return &__asan_init != 0 || &__hwasan_init != 0; } /** /** Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS). Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS). The value to use will be read from the specified system property, or if the The value to use will be read from the specified system property, or if the Loading
services/mediaextractor/seccomp_policy/mediaextractor-arm.policy +1 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ getuid32: 1 setpriority: 1 setpriority: 1 sigaltstack: 1 sigaltstack: 1 openat: 1 openat: 1 open: 1 clone: 1 clone: 1 read: 1 read: 1 clock_gettime: 1 clock_gettime: 1 Loading
services/mediaextractor/seccomp_policy/mediaextractor-x86.policy +1 −0 Original line number Original line Diff line number Diff line Loading @@ -11,6 +11,7 @@ munmap: 1 mmap2: 1 mmap2: 1 madvise: 1 madvise: 1 openat: 1 openat: 1 open: 1 clock_gettime: 1 clock_gettime: 1 writev: 1 writev: 1 brk: 1 brk: 1 Loading