struct pshmstats pshmstats; /* cache effectiveness statistics */
static int pshm_read (struct fileproc *fp, struct uio *uio,
- int flags, vfs_context_t ctx);
+ int flags, vfs_context_t ctx);
static int pshm_write (struct fileproc *fp, struct uio *uio,
- int flags, vfs_context_t ctx);
+ int flags, vfs_context_t ctx);
static int pshm_ioctl (struct fileproc *fp, u_long com,
- caddr_t data, vfs_context_t ctx);
+ caddr_t data, vfs_context_t ctx);
static int pshm_select (struct fileproc *fp, int which, void *wql, vfs_context_t ctx);
static int pshm_close(struct pshminfo *pinfo, int dropref);
static int pshm_closefile (struct fileglob *fg, vfs_context_t ctx);
-static int pshm_kqfilter(struct fileproc *fp, struct knote *kn, vfs_context_t ctx);
+static int pshm_kqfilter(struct fileproc *fp, struct knote *kn,
+ struct kevent_internal_s *kev, vfs_context_t ctx);
int pshm_access(struct pshminfo *pinfo, int mode, kauth_cred_t cred, proc_t p);
int pshm_cache_purge_all(proc_t p);
static int pshm_unlink_internal(struct pshminfo *pinfo, struct pshmcache *pcache);
static const struct fileops pshmops = {
- DTYPE_PSXSHM,
- pshm_read,
- pshm_write,
- pshm_ioctl,
- pshm_select,
- pshm_closefile,
- pshm_kqfilter,
- 0
+ .fo_type = DTYPE_PSXSHM,
+ .fo_read = pshm_read,
+ .fo_write = pshm_write,
+ .fo_ioctl = pshm_ioctl,
+ .fo_select = pshm_select,
+ .fo_close = pshm_closefile,
+ .fo_kqfilter = pshm_kqfilter,
+ .fo_drain = NULL,
};
static lck_grp_t *psx_shm_subsys_lck_grp;
#define PSHM_SUBSYS_LOCK() lck_mtx_lock(& psx_shm_subsys_mutex)
#define PSHM_SUBSYS_UNLOCK() lck_mtx_unlock(& psx_shm_subsys_mutex)
-#define PSHM_SUBSYS_ASSERT_HELD() lck_mtx_assert(&psx_shm_subsys_mutex, LCK_MTX_ASSERT_OWNED)
+#define PSHM_SUBSYS_ASSERT_HELD() LCK_MTX_ASSERT(&psx_shm_subsys_mutex, LCK_MTX_ASSERT_OWNED)
/* Initialize the mutex governing access to the posix shm subsystem */
vm_object_offset_t map_pos;
vm_map_t user_map;
int alloc_flags;
+ vm_map_kernel_flags_t vmk_flags;
boolean_t docow;
kern_return_t kret;
struct pshminfo * pinfo;
PSHM_SUBSYS_UNLOCK();
return(EINVAL);
}
- if ((off_t)user_size > pinfo->pshm_length) {
+ if (user_size > (vm_map_size_t)pinfo->pshm_length) {
PSHM_SUBSYS_UNLOCK();
return(EINVAL);
}
- if ((off_t)(user_size + file_pos) > pinfo->pshm_length) {
+ vm_map_size_t end_pos = 0;
+ if (os_add_overflow(user_size, file_pos, &end_pos)) {
+ PSHM_SUBSYS_UNLOCK();
+ return(EINVAL);
+ }
+ if (end_pos > (vm_map_size_t)pinfo->pshm_length) {
PSHM_SUBSYS_UNLOCK();
return(EINVAL);
}
docow = FALSE;
mapped_size = 0;
-
- /* reserver the entire space first... */
+ vmk_flags = VM_MAP_KERNEL_FLAGS_NONE;
+ /* reserve the entire space first... */
kret = vm_map_enter_mem_object(user_map,
&user_addr,
user_size,
0,
alloc_flags,
+ vmk_flags,
+ VM_KERN_MEMORY_NONE,
IPC_PORT_NULL,
0,
FALSE,
if (map_size > user_size) {
map_size = user_size;
}
+ vmk_flags = VM_MAP_KERNEL_FLAGS_NONE;
kret = vm_map_enter_mem_object(
user_map,
&user_addr,
map_size,
0,
VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE,
+ vmk_flags,
+ VM_KERN_MEMORY_NONE,
pshmobj->pshmo_memobject,
file_pos - map_pos,
docow,
}
static int
-pshm_read(__unused struct fileproc *fp, __unused struct uio *uio,
- __unused int flags, __unused vfs_context_t ctx)
+pshm_read(__unused struct fileproc *fp, __unused struct uio *uio,
+ __unused int flags, __unused vfs_context_t ctx)
{
return(ENOTSUP);
}
static int
-pshm_write(__unused struct fileproc *fp, __unused struct uio *uio,
- __unused int flags, __unused vfs_context_t ctx)
+pshm_write(__unused struct fileproc *fp, __unused struct uio *uio,
+ __unused int flags, __unused vfs_context_t ctx)
{
return(ENOTSUP);
}
static int
-pshm_ioctl(__unused struct fileproc *fp, __unused u_long com,
- __unused caddr_t data, __unused vfs_context_t ctx)
+pshm_ioctl(__unused struct fileproc *fp, __unused u_long com,
+ __unused caddr_t data, __unused vfs_context_t ctx)
{
return(ENOTSUP);
}
static int
-pshm_select(__unused struct fileproc *fp, __unused int which, __unused void *wql,
- __unused vfs_context_t ctx)
+pshm_select(__unused struct fileproc *fp, __unused int which, __unused void *wql,
+ __unused vfs_context_t ctx)
{
return(ENOTSUP);
}
static int
-pshm_kqfilter(__unused struct fileproc *fp, __unused struct knote *kn,
- __unused vfs_context_t ctx)
+pshm_kqfilter(__unused struct fileproc *fp, struct knote *kn,
+ __unused struct kevent_internal_s *kev, __unused vfs_context_t ctx)
{
- return(ENOTSUP);
+ kn->kn_flags = EV_ERROR;
+ kn->kn_data = ENOTSUP;
+ return 0;
}
int