Subject: Weird munmap(2) semantic
To: None <tech-kern@netbsd.org>
From: Charles Hannum <abuse@spamalicious.com>
List: tech-kern
Date: 09/27/2002 15:39:52
In munmap(2), we do this:

        /*
         * interesting system call semantic: make sure entire range is
         * allocated before allowing an unmap.
         */
...
        if (!uvm_map_checkprot(map, addr, addr + size, VM_PROT_NONE)) {
                vm_map_unlock(map);
                return (EINVAL);
        } 

What is the reason for this?  I found a reference claming that spec
1170 required this, but I also found specific references that say none
of Linux, Solaris or AIX implement it this way.

At the very least, it often causes dlclose(3) to fail to unmap memory,
because the munmap(2) returns EINVAL.  (This happens most often on
platforms other than i386, where the data section page alignment is
large, and there are often unmapped pages between the text and data.)

I'm considering removing this check...