Jim Huang
c4947c8879
Use secure random generator on macOS
...
The implementation of arc4random_buf differs from its documentation. It
is documented as "always successful, and no return value is reserved to
indicate an error" for the sake of FreeBSD compatibility [1]. However,
the actual implementation on macOS invokes function "ccrng_generate" [2]
without validating the error cases. It might fail silently[3], which leads
to unexpected source of entropy.
The original arc4random used the RC4 a.k.a. ARC4 algorithm, and ChaCha20
based implementation was introduced in FreeBSD 12.0. Since macOS 10.12,
it was replaced with the NIST-approved AES cipher, and it may be replaced
again in the future as cryptographic techniques advance. Therefore, we
should not assume that arc4random never fails.
On the contrary, CCRandomGenerateBytes(), part of Cryptographic Services [4],
returns cryptographically strong random bits with explicit status code.
This patch properly calls CCRandomGenerateBytes() and checks the status.
[1] https://www.freebsd.org/cgi/man.cgi?query=arc4random_buf
[2] https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60178.40.2/lib/CommonRandom.c.auto.html
[3] https://opensource.apple.com/source/Libc/Libc-1439.40.11/gen/FreeBSD/arc4random.c.auto.html
[4] https://developer.apple.com/documentation/security
2021-06-25 12:37:00 +08:00
Daan Leijen
728be93977
fix for #414 making numa node count atomic
2021-06-17 19:38:51 -07:00
Daan Leijen
a83bca72b3
fixes for M1; disable interpose use zones; fix pedantic warnings
2021-06-17 19:15:09 -07:00
Daan Leijen
c8b5b74500
improve warnings
2021-06-07 17:51:27 -07:00
Daan Leijen
bb957fcd81
Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev
2021-06-07 17:00:35 -07:00
Daan
cd633b2e2a
Merge pull request #411 from jserv/predict-alloc_size
...
Add branch hint for _mi_os_good_alloc_size
2021-06-07 16:55:39 -07:00
Daan Leijen
4ba32c3160
Revert "make all includes relative"
...
This reverts commit 1feb6123d9
.
2021-06-07 16:47:57 -07:00
Daan Leijen
1feb6123d9
make all includes relative
2021-06-06 20:31:36 -07:00
Jim Huang
d48c93af2c
Add branch hint for _mi_os_good_alloc_size
...
In _mi_os_good_alloc_size, overflow caused by alignment size is rare,
and this patch added the appropriate branch hint during range checks.
2021-05-31 12:01:35 +08:00
Daan
16b3329bd4
Merge pull request #396 from jserv/fix-copyright-date
...
Bump copyright date
2021-04-28 13:11:11 -07:00
Daan Leijen
29ea7a89ab
add braces
2021-04-28 13:08:59 -07:00
Daan
6d1658123c
Merge pull request #391 from jserv/improve-align-down
...
Rewrite align_down with bitwise operations
2021-04-28 13:07:13 -07:00
Daan Leijen
aca46242ab
update comment for aligned_alloc
2021-04-28 12:47:14 -07:00
Daan
45a8dc7f55
Merge pull request #385 from elbaro/fix/aligned-alloc
...
Fix aligned_alloc
2021-04-28 12:43:32 -07:00
Jim Huang
5940d3bcce
Bump copyright date
...
Each source file has been changed according to relevant Git activities.
2021-04-24 16:35:11 +00:00
Jim Huang
52943917ad
Rewrite align_down with bitwise operations
...
mi_align_down_ptr was implemented with multiplication and division,
which can be converted to equivalent and deterministic bit operations.
2021-04-21 13:14:53 +00:00
Jim Huang
3402c6cc3f
Revise the use of macOS predefined macro
...
Quoted from "Porting UNIX/Linux Applications to OS X,"[1]
* macro __MACH__ is defined if Mach system calls are supported;
* macro __APPLE__ is defined in any Apple computer.
__MACH__ is not specific to macOS since GNU/Hurd runs on a Mach-based
microkernel (gnumach) [2]. __MACH__ is defined by the compiler,
leading to potential confusions. The solution is just changing the
checked identifier (i.e. __APPLE__), so it is really used only on
macOS.
[1] https://developer.apple.com/library/archive/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html
[2] https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html
2021-04-21 15:24:02 +08:00
elbaro
ad44f76598
commit
2021-04-11 03:09:23 +09:00
Daan Leijen
5f596056c9
use 2-6TiB area for hints to accommodate pre-windows8 better
2021-02-24 15:49:43 -08:00
Daan Leijen
e64474e06b
add virtiual gaps between hinted allocations in secure mode
2021-02-24 15:30:39 -08:00
Daan Leijen
9317256a4f
improved ASLR (issue #372 )
2021-02-24 15:14:17 -08:00
Daan Leijen
3228bb685f
set errno ENOMEM for limited arena allocation (issue #295 )
2021-02-22 14:17:25 -08:00
Daan Leijen
71ac98ab08
rename <Windows.h> include to <windows.h> for mingw compatibility (see pr #367 )
2021-02-22 13:04:11 -08:00
Daan Leijen
7962420697
fix bug in bitmap is_claimed_across; issue #368
2021-02-22 12:37:08 -08:00
Daan Leijen
c426ab4ea2
add condition to avoid compilation error on vs2015 (#issue 353)
2021-02-01 15:41:41 -08:00
Daan Leijen
0091a641a7
undo previous commit dcae918
due to wrong logic (issue #289 )
2021-02-01 09:55:18 -08:00
Daan Leijen
dcae918b84
always do ASLR in secure mode even in debug mode (issue #289 )
2021-02-01 09:49:12 -08:00
Daan Leijen
35c1fc2be9
limit memcpy as rep stosb to windows where the cpu supporst FSRM; add mi_memcpy_aligned for machine-word aligned copy. see issue #201 and pr #253
2021-01-30 14:33:46 -08:00
Daan
9b966c3492
Merge pull request #253 from haneefmubarak/memcpy-rep-movsb-windows-201
...
resolve #201 with a platform-selective REP MOVSB implementation
2021-01-29 16:00:00 -08:00
Daan Leijen
a6fa7b083e
make current stat the third column instead of first
2021-01-29 14:45:16 -08:00
Daan
fb9c6ce127
Merge pull request #327 from asl/stats-cur
...
Print current values of stat counters as well.
2021-01-29 14:35:13 -08:00
Daan Leijen
f68c1a74da
fix assertion comparison ( #353 )
2021-01-29 14:34:14 -08:00
Daan Leijen
a8b282091f
update formatting of statistics
2021-01-29 13:03:06 -08:00
Daan
b759bcf5c7
Merge pull request #329 from asl/mi_stat_agg
...
Unify statistics collection
2021-01-29 12:52:29 -08:00
Daan Leijen
bb386025b5
update override on macOS with interpose of malloc_default_zone (issues #313 )
2020-12-15 16:03:54 -08:00
unknown
745cf1e2f5
fix build on ghc4.8 (issue #330 )
2020-12-10 12:33:35 -08:00
unknown
d1d06b67eb
fix type warning (issue #337 )
2020-12-10 12:13:06 -08:00
unknown
b7087d3625
Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev
2020-12-10 11:57:16 -08:00
Daan
7958d0df57
Merge pull request #331 from devnexen/mi_bitmap_try_find_claim_field_accross_little_chg
...
mi_bitmap_try_find_claim_field_across
2020-12-10 11:57:08 -08:00
unknown
701da6b42e
Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev
2020-12-10 11:53:35 -08:00
Daan
9d0555c65b
Merge pull request #326 from asl/mi_stat_counter
...
Honour MI_STAT in couple more places
2020-12-10 11:53:30 -08:00
unknown
f37a3db37c
cleanup madv_resuable
2020-12-10 11:51:58 -08:00
unknown
cbc14a9287
count warnings and errors separately
2020-12-10 10:28:54 -08:00
Daan
56a1c852ea
Merge pull request #325 from asl/max-error-counter
...
Do not use the same counter for warnings and errors
2020-12-10 10:23:08 -08:00
David Carlier
bbdf470715
mi_bitmap_try_find_claim_field_across
...
number of leading zeros is unsigned.
2020-11-18 17:21:51 +00:00
Anton Korobeynikov
765fc9c0ca
Unify statistic collection:
...
- For MI_STAT == 0 no allocation stats are collected
- For MI_STAT == 1 only aggregated values (across normal, large and huge heaps) are collected
- For MI_STAT == 1 separate per-bin collection for normal heap is done as well
2020-11-11 11:41:39 +03:00
Anton Korobeynikov
00fb89f771
Rename the field
2020-11-11 11:41:33 +03:00
Anton Korobeynikov
d9a0624529
Print current values of stat counters as well.
...
For some reasons unknown to me the current values of stat counters are never printed.
This makes is quite hard to use printing during the debugging in the middle
of program run.
2020-11-02 00:24:24 +03:00
Anton Korobeynikov
39bcf8a6b0
Honour MI_STAT in couple more places.
2020-11-02 00:14:02 +03:00
Anton Korobeynikov
9c45221243
Do not use the same counter for warnings and errors.
...
Warnings happen normally and could be safely ignored in the most cases,
however errors, if enabled, should not be ignored. Currently since warnings
and errors share the same counter we effectively stop showing errors after
16 warnings (which happen all the time).
Use different counters for errors and warnings.
2020-11-01 23:57:42 +03:00