blob: f52652072edb16b81d842f838db59b3a216965b8 [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
21#ifdef __BIONIC__
22#include <bionic/malloc.h>
23#endif
24
25void process_disable_memory_mitigations() {
26 bool success = false;
27#ifdef __BIONIC__
28 // TODO(b/158870657) is fixed and scudo is used globally, we can assert when an
29 // an error is returned.
30
31 success = android_mallopt(M_DISABLE_MEMORY_MITIGATIONS, nullptr, 0);
32#endif
33
34 if (success) {
35 ALOGI("Disabled memory mitigations for process.");
36 } else {
37 ALOGE("Could not disable memory mitigations for process.");
38 }
39}