diff options
author | kib <kib@FreeBSD.org> | 2017-02-26 11:02:14 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2017-02-26 11:02:14 +0000 |
commit | 239438d580b5f8247e175bebd34c2a5a1377015f (patch) | |
tree | c8c352f0e101a1b3663190a8c790dd7173bb3852 /sys/fs | |
parent | 1173a6966c215fd6f21eaf062897bc8e0ced31e1 (diff) | |
download | FreeBSD-src-239438d580b5f8247e175bebd34c2a5a1377015f.zip FreeBSD-src-239438d580b5f8247e175bebd34c2a5a1377015f.tar.gz |
MFC r313967:
Apply noexec mount option for mmap(PROT_EXEC).
PR: 217062
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index afa3da4..e90918f 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -1789,9 +1789,11 @@ devfs_mmap_f(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size, * compatible. */ mp = vp->v_mount; - if (mp != NULL && (mp->mnt_flag & MNT_NOEXEC) != 0) + if (mp != NULL && (mp->mnt_flag & MNT_NOEXEC) != 0) { maxprot = VM_PROT_NONE; - else + if ((prot & VM_PROT_EXECUTE) != 0) + return (EACCES); + } else maxprot = VM_PROT_EXECUTE; if ((fp->f_flag & FREAD) != 0) maxprot |= VM_PROT_READ; |