aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-18 18:32:06 -0400
committerIan Moffett <ian@osmora.org>2024-04-18 18:32:06 -0400
commita6e240d265656408dbe807719dc2f0911c44198f (patch)
treeaf8221598df9072b1bca2343735ded0ba2ece748 /sys
parentb75dd3a112708584a930f85d345835f36a722f5a (diff)
kernel: vm_map: Handle oflag in shared maps
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_map.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index afef6f2..8f7accc 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -191,6 +191,7 @@ vm_fd_map(void *addr, vm_prot_t prot, size_t len, off_t off, int fd)
{
paddr_t physmem = 0;
+ int oflag;
struct filedesc *filedes;
struct vnode *vp;
@@ -204,6 +205,13 @@ vm_fd_map(void *addr, vm_prot_t prot, size_t len, off_t off, int fd)
if ((vp = filedes->vnode) == NULL)
return 0;
+ /* Check the perms of the filedes */
+ oflag = filedes->oflag;
+ if (__TEST(prot, PROT_WRITE) && oflag == O_RDONLY)
+ return 0;
+ if (!__TEST(prot, PROT_WRITE) && oflag == O_WRONLY)
+ return 0;
+
/* Try to create the virtual memory object */
if (vm_obj_init(&vp->vmobj, vp) != 0)
return 0;