Commit Graph

10 Commits

Author SHA1 Message Date
Corinna Vinschen 3e80956d63 Cygwin: cygheap: make bucket_val a static const array
Every time the cygheap is initialized, that is, on each fork
or exec, cygheap_init() *again* computes the bucket size values
and stores them in the cgyheap, albeit they are always the
same values anyway.

Make bucket_val a local const array, statically initialized
instead.

Fixes: 61522196c7 ("* Merge in cygwin-64bit-branch.)"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-28 17:02:05 +02:00
Corinna Vinschen 60675f1a7e Cygwin: decouple shared mem regions from Cygwin DLL
Another reason ASLR may fail is the coupling of the standard shared
mem regions (global, userinfo, process info, shared console) to the
address of the Cygwin DLL.  They are always placed in fixed addresses
preceeding the Cygwin DLL's address.  With ASLR this is bound to fail.

Use a fixed, unused memory area to place the shared mem regions.
This also allows to simplify the shared memory creation.  There's
no reason anymore to rebase the regions and rather than offsets,
just use the addresses directly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-28 16:26:53 +02:00
Corinna Vinschen 2f9b8ff00c Cygwin: decouple cygheap from Cygwin DLL
One reason that ASLR is tricky is the fact that the cygheap
is placed at the end of the DLL and especially that it's expected
to be growable.  To support ASLR, this construct must go.

Define dedicated cygheap memory region and reserve entire region.
Commit 3 Megs, as was the default size of the cygheap before.

Fix linker script accordingly, drop a now useless version check
in get_cygwin_startup_info().
2022-10-28 16:26:53 +02:00
Corinna Vinschen c0776fa7ba Cygwin: add memory_layout.h
Collect all info about memory layout in one header file, so
the mem layout is documented in one logical place and not
in heap.cc arbitrarily.

Use info from this file throughout.

This is to prepare for ASLR support.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-28 16:26:53 +02:00
Corinna Vinschen ee54cabad9 Cygwin: mmap: use SRWLOCK instead of muto
To reduce thread contention, use reader/writer locks as required.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-23 12:09:44 +02:00
Corinna Vinschen 86d2126173 Cygwin: mm/malloc_wrapper.cc: fix a comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen afa7117999 Cygwin: move __caller_return_address to mm/malloc_wrapper.cc
It's used in this file only anyway, so make it static inline.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 5851a633bd Cygwin: make import_address a static inline function
It's used in malloc_init only and we never need it anywhere else,
hopefully.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 56b7fd620f Cygwin: make check_invalid_virtual_addr a static inline function
move it to mm/mmap.cc which uses it exclusively.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 9fbfccff71 Cygwin: move memory management sources into mm subdir
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00