#
484e9d03 |
| 14-Feb-2019 |
Konstantin Belousov <kib@FreeBSD.org> |
Make anon clustering more compatible.
Make the clustering enabling knob more fine-grained by providing a setting where the allocation with hint is not clustered. This is aimed to be somewhat more co
Make anon clustering more compatible.
Make the clustering enabling knob more fine-grained by providing a setting where the allocation with hint is not clustered. This is aimed to be somewhat more compatible with e.g. go 1.4 which expects that hinted mmap without MAP_FIXED does not change the allocation address.
Now the vm.cluster_anon can be set to 1 to only cluster when no hints, and to 2 to always cluster. Default value is 1.
Requested by: peter Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D19194
show more ...
|
#
fa50a355 |
| 10-Feb-2019 |
Konstantin Belousov <kib@FreeBSD.org> |
Implement Address Space Layout Randomization (ASLR)
With this change, randomization can be enabled for all non-fixed mappings. It means that the base address for the mapping is selected with a guar
Implement Address Space Layout Randomization (ASLR)
With this change, randomization can be enabled for all non-fixed mappings. It means that the base address for the mapping is selected with a guaranteed amount of entropy (bits). If the mapping was requested to be superpage aligned, the randomization honours the superpage attributes.
Although the value of ASLR is diminshing over time as exploit authors work out simple ASLR bypass techniques, it elimintates the trivial exploitation of certain vulnerabilities, at least in theory. This implementation is relatively small and happens at the correct architectural level. Also, it is not expected to introduce regressions in existing cases when turned off (default for now), or cause any significant maintaince burden.
The randomization is done on a best-effort basis - that is, the allocator falls back to a first fit strategy if fragmentation prevents entropy injection. It is trivial to implement a strong mode where failure to guarantee the requested amount of entropy results in mapping request failure, but I do not consider that to be usable.
I have not fine-tuned the amount of entropy injected right now. It is only a quantitive change that will not change the implementation. The current amount is controlled by aslr_pages_rnd.
To not spoil coalescing optimizations, to reduce the page table fragmentation inherent to ASLR, and to keep the transient superpage promotion for the malloced memory, locality clustering is implemented for anonymous private mappings, which are automatically grouped until fragmentation kicks in. The initial location for the anon group range is, of course, randomized. This is controlled by vm.cluster_anon, enabled by default.
The default mode keeps the sbrk area unpopulated by other mappings, but this can be turned off, which gives much more breathing bits on architectures with small address space, such as i386. This is tied with the question of following an application's hint about the mmap(2) base address. Testing shows that ignoring the hint does not affect the function of common applications, but I would expect more demanding code could break. By default sbrk is preserved and mmap hints are satisfied, which can be changed by using the kern.elf{32,64}.aslr.honor_sbrk sysctl.
ASLR is enabled on per-ABI basis, and currently it is only allowed on FreeBSD native i386 and amd64 (including compat 32bit) ABIs. Support for additional architectures will be added after further testing.
Both per-process and per-image controls are implemented: - procctl(2) adds PROC_ASLR_CTL/PROC_ASLR_STATUS; - NT_FREEBSD_FCTL_ASLR_DISABLE feature control note bit makes it possible to force ASLR off for the given binary. (A tool to edit the feature control note is in development.) Global controls are: - kern.elf{32,64}.aslr.enable - for non-fixed mappings done by mmap(2); - kern.elf{32,64}.aslr.pie_enable - for PIE image activation mappings; - kern.elf{32,64}.aslr.honor_sbrk - allow to use sbrk area for mmap(2); - vm.cluster_anon - enables anon mapping clustering.
PR: 208580 (exp runs) Exp-runs done by: antoine Reviewed by: markj (previous version) Discussed with: emaste Tested by: pho MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D5603
show more ...
|
#
ea7e7006 |
| 16-Jan-2019 |
Konstantin Belousov <kib@FreeBSD.org> |
Implement shmat(2) flag SHM_REMAP.
Based on the description in Linux man page.
Reviewed by: markj, ngie (previous version) Sponsored by: Mellanox Technologies MFC after: 1 week Differential revisio
Implement shmat(2) flag SHM_REMAP.
Based on the description in Linux man page.
Reviewed by: markj, ngie (previous version) Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18837
show more ...
|
#
67350cb5 |
| 09-Dec-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r340918 through r341763.
|
#
83764b44 |
| 07-Dec-2018 |
Mateusz Guzik <mjg@FreeBSD.org> |
vm: use fcmpset for vmspace reference counting
Sponsored by: The FreeBSD Foundation
|
Revision tags: release/12.0.0 |
|
#
10d9120c |
| 02-Dec-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Change the vm_ooffset_t type to unsigned.
The type represents byte offset in the vm_object_t data space, which does not span negative offsets in FreeBSD VM. The change matches byte offset signess w
Change the vm_ooffset_t type to unsigned.
The type represents byte offset in the vm_object_t data space, which does not span negative offsets in FreeBSD VM. The change matches byte offset signess with the unsignedness of the vm_pindex_t which represents the type of the page indexes in the objects.
This allows to remove the UOFF_TO_IDX() macro which was used when we have to forcibly interpret the type as unsigned anyway. Also it fixes a lot of implicit bugs in the device drivers d_mmap methods.
Reviewed by: alc, markj (previous version) Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
show more ...
|
#
6e00f3a3 |
| 25-Nov-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Avoid unneeded check in vmspace_alloc().
All vmspace_alloc() callers know which kind of pmap they allocate.
Reviewed by: alc, markj (previous version) Sponsored by: The FreeBSD Foundation MFC after
Avoid unneeded check in vmspace_alloc().
All vmspace_alloc() callers know which kind of pmap they allocate.
Reviewed by: alc, markj (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18329
show more ...
|
#
3d5db455 |
| 24-Nov-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r340427 through r340868.
|
#
92e78c10 |
| 18-Nov-2018 |
Alan Cox <alc@FreeBSD.org> |
Tidy up vm_map_simplify_entry() and its recently introduced helper functions. Notably, reflow the text of some comments so that they occupy fewer lines, and introduce an assertion in one of the new
Tidy up vm_map_simplify_entry() and its recently introduced helper functions. Notably, reflow the text of some comments so that they occupy fewer lines, and introduce an assertion in one of the new helper functions so that it is not misused by a future caller.
In collaboration with: Doug Moore <dougm@rice.edu> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D17635
show more ...
|
#
2a22df74 |
| 04-Nov-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r339813 through r340125.
|
#
2203c46d |
| 02-Nov-2018 |
Mark Johnston <markj@FreeBSD.org> |
Initialize the eflags field of vm_map headers.
Initializing the eflags field of the map->header entry to a value with a unique new bit set makes a few comparisons to &map->header unnecessary.
Submi
Initialize the eflags field of vm_map headers.
Initializing the eflags field of the map->header entry to a value with a unique new bit set makes a few comparisons to &map->header unnecessary.
Submitted by: Doug Moore <dougm@rice.edu> Reviewed by: alc, kib Tested by: pho MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D14005
show more ...
|
#
c6879c6c |
| 23-Oct-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r339015 through r339669.
|
#
17afd2be |
| 21-Oct-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Unindent vm_map_simplify_entry() after r339506.
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D17632
|
#
07424462 |
| 21-Oct-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Reduce code duplication in merging vm_entry neighbors.
Submitted by: Doug Moore <dougm@rice.edu> Reviewed by: markj MFC after: 1 week Differential revision: https://reviews.freebsd.org/D17610
|
#
da2d1e9d |
| 29-Aug-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r338298 through r338391.
|
#
f0165b1c |
| 29-Aug-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Remove {max/min}_offset() macros, use vm_map_{max/min}() inlines.
Exposing max_offset and min_offset defines in public headers is causing clashes with variable names, for example when building QEMU.
Remove {max/min}_offset() macros, use vm_map_{max/min}() inlines.
Exposing max_offset and min_offset defines in public headers is causing clashes with variable names, for example when building QEMU.
Based on the submission by: royger Reviewed by: alc, markj (previous version) Sponsored by: The FreeBSD Foundation (kib) MFC after: 1 week Approved by: re (marius) Differential revision: https://reviews.freebsd.org/D16881
show more ...
|
#
14b841d4 |
| 11-Aug-2018 |
Kyle Evans <kevans@FreeBSD.org> |
MFH @ r337607, in preparation for boarding
|
#
737e25f7 |
| 28-Jul-2018 |
Alan Cox <alc@FreeBSD.org> |
To date, mlockall(MCL_FUTURE) has had the unfortunate side effect of blocking vm map entry and object coalescing for the calling process. However, there is no reason that mlockall(MCL_FUTURE) should
To date, mlockall(MCL_FUTURE) has had the unfortunate side effect of blocking vm map entry and object coalescing for the calling process. However, there is no reason that mlockall(MCL_FUTURE) should block such coalescing. This change enables it.
Reviewed by: kib, markj Tested by: pho MFC after: 6 weeks Differential Revision: https://reviews.freebsd.org/D16413
show more ...
|
#
32f0fefc |
| 06-Jul-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Save a call to pmap_remove() if entry cannot have any pages mapped.
Due to the way rtld creates mappings for the shared objects, each dso causes unmap of at least three guard map entries. For insta
Save a call to pmap_remove() if entry cannot have any pages mapped.
Due to the way rtld creates mappings for the shared objects, each dso causes unmap of at least three guard map entries. For instance, in the buildworld load, this change reduces the amount of pmap_remove() calls by 1/5.
Profiled by: alc Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D16148
show more ...
|
#
be7be412 |
| 06-Jul-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Style: no need for braces around single-line then clause.
Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D16148
|
Revision tags: release/11.2.0 |
|
#
3e7cb27c |
| 04-Jun-2018 |
Alan Cox <alc@FreeBSD.org> |
Use a single, consistent approach to returning success versus failure in vm_map_madvise(). Previously, vm_map_madvise() used a traditional Unix- style "return (0);" to indicate success in the common
Use a single, consistent approach to returning success versus failure in vm_map_madvise(). Previously, vm_map_madvise() used a traditional Unix- style "return (0);" to indicate success in the common case, but Mach- style return values in the edge cases. Since KERN_SUCCESS equals zero, the only problem with this inconsistency was stylistic. vm_map_madvise() has exactly two callers in the entire source tree, and only one of them cares about the return value. That caller, kern_madvise(), can be simplified if vm_map_madvise() consistently uses Unix-style return values.
Since vm_map_madvise() uses the variable modify_map as a Boolean, make it one.
Eliminate a redundant error check from kern_madvise(). Add a comment explaining where the check is performed.
Explicitly note that exec_release_args_kva() doesn't care about vm_map_madvise()'s return value. Since MADV_FREE is passed as the behavior, the return value will always be zero.
Reviewed by: kib, markj MFC after: 7 days
show more ...
|
#
19ea042e |
| 30-Mar-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Make vm_map_max/min/pmap KBI stable.
There are out of tree consumers of vm_map_min() and vm_map_max(), and I believe there are consumers of vm_map_pmap(), although the later is arguably less in the
Make vm_map_max/min/pmap KBI stable.
There are out of tree consumers of vm_map_min() and vm_map_max(), and I believe there are consumers of vm_map_pmap(), although the later is arguably less in the need of KBI-stable interface. For the consumers benefit, make modules using this KPI not depended on the struct vm_map layout.
Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D14902
show more ...
|
#
e2068d0b |
| 06-Feb-2018 |
Jeff Roberson <jeff@FreeBSD.org> |
Use per-domain locks for vm page queue free. Move paging control from global to per-domain state. Protect reservations with the free lock from the domain that they belong to. Refactor to make vm d
Use per-domain locks for vm page queue free. Move paging control from global to per-domain state. Protect reservations with the free lock from the domain that they belong to. Refactor to make vm domains more of a first class object.
Reviewed by: markj, kib, gallatin Tested by: pho Sponsored by: Netflix, Dell/EMC Isilon Differential Revision: https://reviews.freebsd.org/D14000
show more ...
|
#
1c5196c3 |
| 20-Jan-2018 |
Konstantin Belousov <kib@FreeBSD.org> |
Assign map->header values to avoid boundary checks.
In several places, entry start and end field are checked, after excluding the possibility that the entry is map->header. By assigning max and min
Assign map->header values to avoid boundary checks.
In several places, entry start and end field are checked, after excluding the possibility that the entry is map->header. By assigning max and min values to the start and end fields of map->header in vm_map_init, the explicit map->header checks become unnecessary.
Submitted by: Doug Moore <dougm@rice.edu> Reviewed by: alc, kib, markj (previous version) Tested by: pho (previous version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D13735
show more ...
|
#
4fc74049 |
| 29-Dec-2017 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r327169 through r327340.
|