From 6ee7dd87bacb866bfff2a19605da9fc27d561c53 Mon Sep 17 00:00:00 2001 From: Alexander Kabaev Date: Mon, 1 Dec 2008 22:33:50 +0000 Subject: [PATCH] Shared memory objects that have size which is not necessarily equal to exact multiple of system page size should still be allowed to be mapped in their entirety to match the regular vnode backed file behavior. Reported by: ed Reviewed by: jhb --- sys/kern/uipc_shm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index f2dec1971cd..a12c731acdc 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -605,7 +605,8 @@ shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, * XXXRW: This validation is probably insufficient, and subject to * sign errors. It should be fixed. */ - if (foff >= shmfd->shm_size || foff + objsize > shmfd->shm_size) + if (foff >= shmfd->shm_size || + foff + objsize > round_page(shmfd->shm_size)) return (EINVAL); mtx_lock(&shm_timestamp_lock);