From 497a82382bd211712ddbddcf381af875be8a37da Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 20 Sep 2009 12:40:56 +0000 Subject: [PATCH] Old (a.out) rtld attempts to mmap zero-length region, e.g. when bss of the linked object is zero-length. More old code assumes that mmap of zero length returns success. For a.out and pre-8 ELF binaries, allow the mmap of zero length. Reported by: tegge Reviewed by: tegge, alc, jhb MFC after: 3 days --- sys/vm/vm_mmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 2b99e3653df..c8d25ee3a30 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -229,7 +230,8 @@ mmap(td, uap) fp = NULL; /* make sure mapping fits into numeric range etc */ - if (uap->len == 0 || + if ((uap->len == 0 && !SV_CURPROC_FLAG(SV_AOUT) && + curproc->p_osrel >= 800104) || ((flags & MAP_ANON) && uap->fd != -1)) return (EINVAL);