Daniel Micay
d3152b8e8f
preserve errno for free calls
...
This is a future POSIX requirement recently implemented by musl and
glibc.
2023-02-17 13:07:26 -05:00
Daniel Micay
2e9daf3122
merge fprintf/fputs calls in malloc_info
2023-02-17 13:07:26 -05:00
Daniel Micay
6038030d0b
no need to check for -fstack-clash-protection
...
This is supported by the compiler versions listed as minimum
requirements in the README.
2023-02-17 13:07:26 -05:00
Daniel Micay
4d23fa37ad
enable Intel CET support
2023-02-17 13:07:26 -05:00
Daniel Micay
6d36e758f5
update copyright notice
2023-02-17 13:07:26 -05:00
Daniel Micay
cd9b875297
reorganize compiler switches
2023-02-17 13:07:24 -05:00
Daniel Micay
2250130c53
remove unnecessary UNUSED marker
2022-09-16 01:03:47 -04:00
Daniel Micay
72dba6765f
disable tidy identifier length lint
2022-09-16 00:57:08 -04:00
Daniel Micay
8f38bbdee6
add configuration for self-init
...
This needs to be disabled for compatibility with the exploit protection
compatibility mode on GrapheneOS. hardened_malloc shouldn't be trying to
initialize itself when exploit protection compatibility mode is enabled.
This has to be handled in our Bionic integration instead.
2022-09-14 03:41:31 -04:00
Daniel Micay
dd427cb3b8
arm64 page table / page size docs
2022-09-08 23:17:25 -04:00
Daniel Micay
b5dd9d11d9
raise class region size to 32GB for arm64 Android
2022-09-08 23:13:15 -04:00
Daniel Micay
72fb3576f5
Android 13 is now all we'll be supporting
2022-08-16 07:48:47 -04:00
Daniel Micay
0d6d63cbe7
improve package installation for CI
2022-03-11 22:09:13 -05:00
Daniel Micay
448170a412
fix case for non-macro constant
2022-01-21 23:59:37 -05:00
Daniel Micay
995ce07d45
add is_init likely/unlikely markers
2022-01-21 19:46:49 -05:00
Daniel Micay
c9d1abcd7e
explicitly mark fatal error conditions unlikely
2022-01-21 19:45:05 -05:00
Daniel Micay
8f0b252c33
mark more out-of-memory conditions as unlikely
2022-01-21 19:03:02 -05:00
Daniel Micay
3cffc1e1af
treat zero size malloc as unlikely
...
Calls to malloc with a zero size are extremely rare relative to normal
usage of the API. It's generally only done by inefficient C code with
open coded dynamic array implementations where they aren't handling zero
size as a special case for their usage of malloc/realloc. Efficient code
wouldn't be making these allocations. It doesn't make sense to optimize
for the performance of rare edge cases caused by inefficient code.
2022-01-21 18:27:04 -05:00
Daniel Micay
ae2524bf88
ignore environment for test Makefile variables
2022-01-21 16:24:49 -05:00
Daniel Micay
e28addda19
add back gitignore entries
2022-01-21 15:07:13 -05:00
Daniel Micay
9d89712386
remove extra newline
2022-01-21 15:06:29 -05:00
Daniel Micay
0bbcc5d610
malloc.c was renamed to h_malloc.c
2022-01-19 16:42:12 -05:00
Daniel Micay
b3d78bd5f6
use static const for local constants
2022-01-16 21:02:17 -05:00
Daniel Micay
8d61e63274
add comment about special small size classes
2022-01-16 20:50:49 -05:00
Daniel Micay
422ee78b3e
reorganize pages.h header
2022-01-16 16:57:22 -05:00
Daniel Micay
3e312695e1
document clz64/log2u64 not being able to handle 0
2022-01-16 16:28:49 -05:00
Daniel Micay
81cf2f27a0
calculate slab size class instead of array loop
2022-01-16 16:18:14 -05:00
Daniel Micay
d8cb2d9f7a
use consistent wrappers around clz/ffs
2022-01-16 15:39:59 -05:00
Daniel Micay
86f9c739ee
define constant for u64 bit width
2022-01-16 15:06:36 -05:00
Daniel Micay
536f852538
reuse a single size alignment implementation
2022-01-16 14:44:28 -05:00
Daniel Micay
e814cf4f5c
enable linking optimization for GNU linker
2022-01-16 12:18:00 -05:00
Daniel Micay
705211ef49
define UBSan flags for SHARED_FLAGS to reuse it
2022-01-16 11:50:55 -05:00
Daniel Micay
189d3362d5
enable sized deallocation ABI for consistency
2022-01-16 11:49:51 -05:00
Daniel Micay
e2bcf4a356
stop silencing constant logical operand warning
...
This was resolved by 3696f071a4 .
2022-01-13 14:51:22 -05:00
Daniel Micay
d470ae56a5
switch Android build to C17 from C11
2022-01-13 14:48:56 -05:00
Daniel Micay
42b097f3b0
CONFIG_SEAL_METADATA is regularly tested now
2022-01-13 14:25:41 -05:00
Daniel Micay
17891d743e
switch from c11 to c17 standard
2022-01-12 10:20:47 -05:00
Daniel Micay
efd71e70c7
update documentation based on light configuration
2022-01-12 08:58:00 -05:00
Daniel Micay
a6d27848af
wrap overly long line
2022-01-12 08:44:39 -05:00
Daniel Micay
110126d7f0
README: fix path to configuration templates
2022-01-12 08:43:36 -05:00
Daniel Micay
a2bdb4da27
update gitignore for renamed / added tests
2022-01-12 08:41:21 -05:00
Daniel Micay
0c0561e563
update gitignore for config template system
2022-01-12 08:41:12 -05:00
Daniel Micay
5a577e9ee0
document configuration template system
2022-01-12 08:38:33 -05:00
Daniel Micay
b3372e1576
add configuration template system
2022-01-10 04:47:01 -05:00
Daniel Micay
2a5662948e
rename bitmap manipulation functions
2022-01-04 12:14:55 -05:00
Daniel Micay
d1c39edc9b
use const for malloc_object_size API
2022-01-04 10:14:41 -05:00
Daniel Micay
aa1746a90d
alloc_size attribute for legacy valloc function
2022-01-04 10:04:26 -05:00
Daniel Micay
f3efc26638
add malloc attribute where appropriate
2022-01-04 09:56:29 -05:00
Daniel Micay
8a500088c6
add missing include for overflow tests
2022-01-03 21:24:31 -05:00
Daniel Micay
c50d06bc6a
comment explaining XOR for 8 byte overflow test
2022-01-03 21:23:14 -05:00
Daniel Micay
645414cc9f
add 1 byte overflow tests
2022-01-03 21:20:15 -05:00
Daniel Micay
13a1f578cb
use calculated size for overflow tests
...
This greatly reduces how much these tests depend on hard-wired knowledge
about the size classes.
2022-01-03 21:11:31 -05:00
Daniel Micay
acda766e2c
fix small allocation canary overwrite test
...
Overwriting one byte of a canary with 0 has a 1/256 chance of not
triggering the expected failure.
2022-01-03 21:08:14 -05:00
Daniel Micay
5f32942263
get rid of canary_value when canaries are disabled
2022-01-03 20:39:30 -05:00
Daniel Micay
346529574d
check whole allocation for uninit read large test
2022-01-03 17:55:05 -05:00
Daniel Micay
16c991b8f7
use 256k for large allocation tests
2022-01-03 16:11:16 -05:00
Daniel Micay
3696f071a4
use SLAB_CANARY for conditional checks
2022-01-03 02:17:04 -05:00
Daniel Micay
7d6663ed80
update copyright notice
2022-01-03 01:41:27 -05:00
Daniel Micay
c6af50d088
use unsigned for ffzl definition
...
This makes more sense and avoids clang tidy conversion warnings.
2022-01-03 01:29:12 -05:00
Daniel Micay
8ae78237ae
avoid unnecessarily mixing 32-bit and 64-bit ints
...
It's ever so slightly faster to stick to stick to 64-bit arithmetic and
it avoids clang tidy being unhappy about the implicit widening.
2022-01-03 00:54:43 -05:00
Daniel Micay
3f8e9d3184
make MREMAP_MOVE_THRESHOLD into size_t constant
...
This avoids a clang-tidy warning and is a bit cleaner.
2022-01-03 00:32:06 -05:00
Daniel Micay
1e526fc36b
disable incredibly impractical clang-tidy check
...
bugprone-easily-swappable-parameters is completely impractical for real
world usage. It's a reasonable thing to consider as part of API design
but it mostly applies to having APIs taking a lot of parameters. It's
unreasonable to disallow APIs simply taking 2 integer parameters even as
a loose guideline.
2022-01-03 00:27:49 -05:00
Daniel Micay
de7a3b6e5a
enable sized deallocation for sized deletion test
...
Clang doesn't currently enable sized deallocation by default like GCC.
2022-01-01 23:18:52 -05:00
Daniel Micay
75e26afdb6
remove legacy safe_flag check for -fno-plt
...
This is supported by the minimum versions of the dependencies.
2021-12-30 19:17:33 -05:00
Daniel Micay
4ccd6f16df
always enable C++17
...
The safe_flag check doesn't work properly for C++ flags with Clang so
this wasn't getting enabled despite the conditional compilation being
removed from the code, leading to breaking Clang builds.
2021-12-26 16:26:38 -05:00
Daniel Micay
460fef456d
only Android 12 is supported
2021-12-13 19:42:40 -05:00
Daniel Micay
1a650b0317
update copyright notice
2021-12-13 19:42:33 -05:00
Daniel Micay
d8817417cc
use compiler extension instead of C11 noreturn
...
C11 noreturn isn't available in C++.
2021-11-23 16:00:06 -05:00
Daniel Micay
7106bff27f
update required dependencies
2021-11-23 15:53:03 -05:00
Daniel Micay
aa94408cc2
fix wording
2021-10-19 23:52:18 -04:00
Daniel Micay
8f9305df57
Android 12 is supported
2021-10-08 13:44:28 -04:00
Daniel Micay
3b72a4f810
set C / C++ standard parameter for clang-tidy
2021-09-30 11:05:47 -04:00
Daniel Micay
e41d37c3de
remove unnecessary else
2021-09-30 10:57:05 -04:00
Daniel Micay
23969727d8
disable readability-function-cognitive-complexity
2021-09-30 10:55:12 -04:00
Daniel Micay
4d30b491e3
set up dependabot for GitHub Actions
2021-09-30 01:18:36 -04:00
Daniel Micay
11207a9c98
add GitHub workflow for building and running tests
2021-09-30 01:17:08 -04:00
Daniel Micay
801e8d959f
disable mallinfo2 test for old glibc
2021-09-30 01:16:10 -04:00
Daniel Micay
8dfea34fc0
current AOSP stable branch is Android 11 QPR3
2021-09-05 01:59:45 -04:00
Daniel Micay
4d6456cf58
update libdivide to 5.0.0
2021-07-17 14:58:47 -04:00
Daniel Micay
be6dde66f9
fix missing include for Intel MPK support
2021-05-21 09:07:28 -04:00
Daniel Micay
e0ecacff45
drop support for legacy C++ versions
2021-05-21 09:00:39 -04:00
Daniel Micay
050871122b
update non-Android max_map_count recommendation
2021-05-13 19:50:35 -04:00
Daniel Micay
27fcfccb67
make __GLIBC_PREREQ check for mallinfo2 portable
2021-05-12 22:53:20 -04:00
Daniel Micay
93a87ce30b
add new mallinfo2 test to gitignore too
2021-05-12 21:13:06 -04:00
Daniel Micay
da190f1469
mark pvalloc error path as unlikely
2021-05-12 21:01:13 -04:00
Daniel Micay
b0f81365a8
reuse code for aligned allocation API entry points
2021-05-12 20:59:04 -04:00
Daniel Micay
c9820b6e37
mark alloc_aligned_simple error path unlikely
2021-05-12 20:41:46 -04:00
Daniel Micay
f1cdc1e484
remove disconcerting newline
2021-05-12 20:34:18 -04:00
Daniel Micay
26b74b87bf
improve code reuse for malloc API entry points
2021-05-12 20:28:50 -04:00
Daniel Micay
89faba4232
set errno in malloc_get_state to match glibc
2021-05-12 20:19:12 -04:00
Daniel Micay
a45dacc57b
add support for glibc mallinfo2
2021-05-12 20:07:15 -04:00
Daniel Micay
a71ab1a2eb
MREMAP_DONTUNMAP may be usable in realloc
2021-05-12 10:51:52 -04:00
Daniel Micay
96a322bcbe
raise max_map_count recommendation
2021-05-12 10:32:59 -04:00
Daniel Micay
92a1e456d2
use normal class region size on x86_64 Android
2021-05-12 05:11:30 -04:00
Daniel Micay
9706f5a311
increase class region size on Android to 2GiB
2021-05-12 03:07:33 -04:00
Daniel Micay
440489af67
purge memory if munmap fails
2021-05-12 01:05:39 -04:00
Daniel Micay
f9a8e7216b
purge slab memory even if using MAP_FIXED fails
2021-05-12 00:45:19 -04:00
Daniel Micay
5c974bdf82
use region quarantine even if MAP_FIXED call fails
...
This is a more sensible way of handling an out-of-memory failure in this
edge case. It doesn't matter much in practice.
2021-05-12 00:20:03 -04:00
Daniel Micay
2335f56713
add wrapper function for getting slot count
2021-05-10 07:04:50 -04:00
Daniel Micay
13a3aa16d0
improve naming of adjust_size_for_canaries
2021-05-07 04:23:49 -04:00