[Bug 217062] for file systems mounted with -o noexec, exec=off property does not work for mmap

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Feb 14 10:42:23 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217062

--- Comment #3 from shamaz.mazum at gmail.com ---
Created attachment 179980
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=179980&action=edit
Minimal test

(In reply to Konstantin Belousov from comment #2)

Oh, I thought noexec means complete 100% protection from any execution ;) But I
have some doubts. What does the following code means in sys/kern/vfs_vnops.c ?

        /*
         * Ensure that file and memory protections are
         * compatible.  Note that we only worry about
         * writability if mapping is shared; in this case,
         * current and max prot are dictated by the open file.
         * XXX use the vnode instead?  Problem is: what
         * credentials do we use for determination? What if
         * proc does a setuid?
         */
        mp = vp->v_mount;
        if (mp != NULL && (mp->mnt_flag & MNT_NOEXEC) != 0)
                maxprot = VM_PROT_NONE;
        else
                maxprot = VM_PROT_EXECUTE;
        if ((fp->f_flag & FREAD) != 0)
                maxprot |= VM_PROT_READ;
        else if ((prot & VM_PROT_READ) != 0)
                return (EACCES);

The source is vn_map() function in source src/sys/kern/vfs_vnops.c
A minimal test as you asked. Compile it and launch with any file on no-exec
filesystem as its only argument. It tries to do mmap() and mprotect() and
returns results

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-fs mailing list