blob: a899d80a315e0a3b84fa12efaf50d90b4c5b5464 [file] [log] [blame]
Steven Morelandd22659b2020-10-05 23:20:11 +00001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <cutils/memory.h>
18
19#include <log/log.h>
20
Elliott Hughes66304a02021-01-15 11:04:10 -080021#include <malloc.h>
Steven Morelandd22659b2020-10-05 23:20:11 +000022
23void process_disable_memory_mitigations() {
24 bool success = false;
25#ifdef __BIONIC__
Elliott Hughes66304a02021-01-15 11:04:10 -080026 success = mallopt(M_BIONIC_DISABLE_MEMORY_MITIGATIONS, 0);
Steven Morelandd22659b2020-10-05 23:20:11 +000027#endif
28
Elliott Hughes66304a02021-01-15 11:04:10 -080029 // TODO: if b/158870657 is fixed and scudo is used globally,
30 // we can assert on failure rather than just log.
Steven Morelandd22659b2020-10-05 23:20:11 +000031 if (success) {
32 ALOGI("Disabled memory mitigations for process.");
33 } else {
34 ALOGE("Could not disable memory mitigations for process.");
35 }
36}