/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
*
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/stat.h>
#include <sys/ubc.h>
+#include <bsm/audit_kernel.h>
+#include <bsm/audit_kevents.h>
+
#include <mach/mach_types.h>
#include <kern/cpu_number.h>
long pos;
};
+int
osmmap(curp, uap, retval)
struct proc *curp;
register struct osmmap_args *uap;
user_addr = (vm_offset_t)uap->addr;
user_size = (vm_size_t) uap->len;
+ AUDIT_ARG(addr, (void *)user_addr);
+ AUDIT_ARG(len, (int) user_size);
+ AUDIT_ARG(fd, uap->fd);
+
prot = (uap->prot & VM_PROT_ALL);
flags = uap->flags;
if (err)
return(err);
if(fp->f_type == DTYPE_PSXSHM) {
- uap->addr = user_addr;
+ uap->addr = (caddr_t)user_addr;
uap->len = user_size;
uap->prot = prot;
uap->flags = flags;
if (vp->v_type != VREG && vp->v_type != VCHR)
return (EINVAL);
+
+ AUDIT_ARG(vnpath, vp, ARG_VNODE1);
+
/*
* XXX hack to handle use of /dev/zero to map anon memory (ala
* SunOS).
*/
if (vp->v_type == VCHR || vp->v_type == VSTR) {
- return(EOPNOTSUPP);
+ return(ENODEV);
} else {
/*
* Ensure that file and memory protections are
if (result != KERN_SUCCESS)
goto out;
+ result = vm_protect(user_map, user_addr, user_size, TRUE, maxprot);
+ if (result != KERN_SUCCESS)
+ goto out;
+ result = vm_protect(user_map, user_addr, user_size, FALSE, prot);
+ if (result != KERN_SUCCESS)
+ goto out;
+
} else {
UBCINFOCHECK("mmap", vp);
- pager = ubc_getpager(vp);
+ pager = (vm_pager_t)ubc_getpager(vp);
if (pager == NULL)
return (ENOMEM);
ubc_map(vp);
}
- if (flags & (MAP_SHARED|MAP_INHERIT)) {
+ if (flags & MAP_SHARED) {
result = vm_inherit(user_map, user_addr, user_size,
VM_INHERIT_SHARE);
if (result != KERN_SUCCESS) {
user_map = current_map();
+ if ((flags & (MS_ASYNC|MS_SYNC)) == (MS_ASYNC|MS_SYNC))
+ return (EINVAL);
+
if ((flags & (MS_ASYNC|MS_INVALIDATE)) == (MS_ASYNC|MS_INVALIDATE))
return (EINVAL);
* inaccurate results, lets just return error as invalid size
* specified
*/
- return(EINVAL);
+ return (EINVAL); /* XXX breaks posix apps */
}
if (flags & MS_KILLPAGES)
}
return (0);
-
}
+int
mremap()
{
/* Not yet implemented */
caddr_t addr;
int len;
};
+int
munmap(p, uap, retval)
struct proc *p;
struct munmap_args *uap;
user_addr = (vm_offset_t) uap->addr;
user_size = (vm_size_t) uap->len;
+ AUDIT_ARG(addr, (void *)user_addr);
+ AUDIT_ARG(len, (int) user_size);
+
pageoff = (user_addr & PAGE_MASK);
user_addr -= pageoff;
kern_return_t result;
vm_map_t user_map;
+ AUDIT_ARG(addr, uap->addr);
+ AUDIT_ARG(len, uap->len);
+ AUDIT_ARG(value, uap->prot);
user_addr = (vm_offset_t) uap->addr;
user_size = (vm_size_t) uap->len;
prot = (vm_prot_t)(uap->prot & VM_PROT_ALL);
vm_map_t user_map;
kern_return_t result;
+ AUDIT_ARG(addr, uap->addr);
+ AUDIT_ARG(len, uap->len);
+ AUDIT_ARG(value, uap->inherit);
addr = (vm_offset_t)uap->addr;
size = uap->len;
inherit = uap->inherit;
int error;
kern_return_t result;
+ AUDIT_ARG(addr, uap->addr);
+ AUDIT_ARG(len, uap->len);
addr = (vm_offset_t) uap->addr;
size = uap->len;
vm_map_t user_map;
kern_return_t result;
+ AUDIT_ARG(addr, uap->addr);
+ AUDIT_ARG(len, uap->len);
addr = (vm_offset_t) uap->addr;
size = uap->len;
struct obreak_args {
char *nsiz;
};
+int
obreak(p, uap, retval)
struct proc *p;
struct obreak_args *uap;
int both;
+int
ovadvise()
{
#endif
}
/* END DEFUNCT */
-#if 1
-int print_map_addr=0;
-#endif /* 1 */
/* CDY need to fix interface to allow user to map above 32 bits */
-kern_return_t map_fd(
+/* USV: No! need to obsolete map_fd()! mmap() already supports 64 bits */
+kern_return_t
+map_fd(
int fd,
vm_offset_t offset,
vm_offset_t *va,
kern_return_t ret;
boolean_t funnel_state;
+ AUDIT_MACH_SYSCALL_ENTER(AUE_MAPFD);
+ AUDIT_ARG(addr, va);
+ AUDIT_ARG(fd, fd);
+
funnel_state = thread_funnel_set(kernel_flock, TRUE);
ret = map_fd_funneled( fd, (vm_object_offset_t)offset,
(void) thread_funnel_set(kernel_flock, FALSE);
+ AUDIT_MACH_SYSCALL_EXIT(ret);
return ret;
}
-kern_return_t map_fd_funneled(
+kern_return_t
+map_fd_funneled(
int fd,
vm_object_offset_t offset,
vm_offset_t *va,
int err=0;
vm_map_t my_map;
struct proc *p =(struct proc *)current_proc();
-#if 0
- extern int print_map_addr;
-#endif /* 0 */
/*
* Find the inode; verify that it's a regular file.
if (vp->v_type != VREG)
return (KERN_INVALID_ARGUMENT);
+ AUDIT_ARG(vnpath, vp, ARG_VNODE1);
+
if (offset & PAGE_MASK_64) {
printf("map_fd: file offset not page aligned(%d : %s)\n",p->p_pid, p->p_comm);
return (KERN_INVALID_ARGUMENT);