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 | |
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
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 6 |
2 files changed, 8 insertions, 4 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; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6743284..f9da22b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2434,9 +2434,11 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size, * proc does a setuid? */ 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; |