08849e56ba
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 |
||
---|---|---|
.. | ||
addr2line | ||
alias | ||
apply | ||
ar | ||
asa | ||
at | ||
atm | ||
awk | ||
banner | ||
basename | ||
bc | ||
biff | ||
bluetooth | ||
bmake | ||
brandelf | ||
bsdcat | ||
bsdiff | ||
bzip2 | ||
bzip2recover | ||
c89 | ||
c99 | ||
caesar | ||
calendar | ||
cap_mkdb | ||
chat | ||
chkey | ||
chpass | ||
cksum | ||
clang | ||
cmp | ||
col | ||
colldef | ||
colrm | ||
column | ||
comm | ||
compile_et | ||
compress | ||
cpio | ||
cpuset | ||
csplit | ||
ctags | ||
ctlstat | ||
cut | ||
cxxfilt | ||
dc | ||
diff | ||
diff3 | ||
dirname | ||
dpv | ||
drill | ||
dtc | ||
du | ||
ee | ||
elf2aout | ||
elfdump | ||
enigma | ||
env | ||
etdump | ||
expand | ||
factor | ||
false | ||
fetch | ||
file | ||
file2c | ||
find | ||
finger | ||
fmt | ||
fold | ||
fortune | ||
from | ||
fstat | ||
fsync | ||
ftp | ||
gcore | ||
gencat | ||
getaddrinfo | ||
getconf | ||
getent | ||
getopt | ||
gprof | ||
grdc | ||
grep | ||
gzip | ||
head | ||
hesinfo | ||
hexdump | ||
host | ||
iconv | ||
id | ||
ident | ||
indent | ||
ipcrm | ||
ipcs | ||
iscsictl | ||
join | ||
jot | ||
kdump | ||
keylogin | ||
keylogout | ||
killall | ||
ktrace | ||
ktrdump | ||
lam | ||
last | ||
lastcomm | ||
ldd | ||
leave | ||
less | ||
lessecho | ||
lesskey | ||
lex | ||
limits | ||
locale | ||
localedef | ||
locate | ||
lock | ||
lockf | ||
logger | ||
login | ||
logins | ||
logname | ||
look | ||
lorder | ||
lsvfs | ||
lzmainfo | ||
m4 | ||
man | ||
mandoc | ||
mesg | ||
minigzip | ||
ministat | ||
mkcsmapper | ||
mkcsmapper_static | ||
mkdep | ||
mkesdb | ||
mkesdb_static | ||
mkfifo | ||
mkimg | ||
mklocale | ||
mkstr | ||
mktemp | ||
mkuzip | ||
morse | ||
msgs | ||
mt | ||
nc | ||
ncal | ||
netstat | ||
newgrp | ||
newkey | ||
nfsstat | ||
nice | ||
nl | ||
nm | ||
nohup | ||
number | ||
objcopy | ||
ofed | ||
opieinfo | ||
opiekey | ||
opiepasswd | ||
pagesize | ||
pamtest | ||
passwd | ||
paste | ||
patch | ||
pathchk | ||
perror | ||
pom | ||
pr | ||
primes | ||
printenv | ||
printf | ||
proccontrol | ||
procstat | ||
protect | ||
quota | ||
random | ||
rctl | ||
readelf | ||
renice | ||
resizewin | ||
rev | ||
revoke | ||
rpcgen | ||
rpcinfo | ||
rs | ||
rup | ||
ruptime | ||
rusers | ||
rwall | ||
rwho | ||
script | ||
sdiff | ||
sdiotool | ||
sed | ||
seq | ||
setchannel | ||
shar | ||
showmount | ||
size | ||
smbutil | ||
sockstat | ||
soelim | ||
sort | ||
split | ||
ssh-copy-id | ||
stat | ||
stdbuf | ||
strings | ||
su | ||
svn | ||
systat | ||
tabs | ||
tail | ||
talk | ||
tar | ||
tcopy | ||
tee | ||
telnet | ||
tests | ||
tftp | ||
time | ||
timeout | ||
tip | ||
top | ||
touch | ||
tput | ||
tr | ||
true | ||
truncate | ||
truss | ||
tset | ||
tsort | ||
tty | ||
ul | ||
uname | ||
unexpand | ||
unifdef | ||
uniq | ||
units | ||
unvis | ||
unzip | ||
usbhidaction | ||
usbhidctl | ||
users | ||
uudecode | ||
uuencode | ||
vacation | ||
vgrind | ||
vi | ||
vis | ||
vmstat | ||
vtfontcvt | ||
w | ||
wall | ||
wc | ||
what | ||
whereis | ||
which | ||
who | ||
whois | ||
write | ||
xargs | ||
xinstall | ||
xo | ||
xohtml | ||
xolint | ||
xopo | ||
xstr | ||
xz | ||
xzdec | ||
yacc | ||
yes | ||
ypcat | ||
ypmatch | ||
ypwhich | ||
zstd | ||
Makefile | ||
Makefile.amd64 | ||
Makefile.arm | ||
Makefile.i386 | ||
Makefile.inc | ||
Makefile.powerpc | ||
Makefile.sparc64 |