bsd-user/mmap.c: Don't mmap fd == -1 independently from MAP_ANON flag
authorWarner Losh <imp@bsdimp.com>
Mon, 18 Oct 2021 18:51:17 +0000 (12:51 -0600)
committerWarner Losh <imp@bsdimp.com>
Mon, 18 Oct 2021 18:51:17 +0000 (12:51 -0600)
commita6b2d060667422d54e077c0a8e4c55bd083ef489
tree95e70b0622b54456329c2157e42a7d96493b4481
parent45b8765e8f3001436c09cebcd9b8b281e6c55804
bsd-user/mmap.c: Don't mmap fd == -1 independently from MAP_ANON flag

Switch checks for !(flags & MAP_ANONYMOUS) with checks for fd != -1.
MAP_STACK and MAP_GUARD both require fd == -1 and don't require mapping
the fd either. Add analysis from Guy Yur detailing the different cases
for MAP_GUARD and MAP_STACK.

Signed-off-by: Guy Yur <guyyur@gmail.com>
[ partially merged before, finishing the job and documenting origin]
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
bsd-user/mmap.c