summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'ipc')
-rw-r--r--ipc/shm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 1b3855450..508b6a3c9 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -840,6 +840,15 @@ static struct page * shm_nopage(struct vm_area_struct * shmd, unsigned long addr
idx = (address - shmd->vm_start) >> PAGE_SHIFT;
idx += shmd->vm_pgoff;
+ /*
+ * A shared mapping past the last page of the file is an error
+ * and results in a SIGBUS, so logically a shared mapping past
+ * the end of a shared memory segment should result in SIGBUS
+ * as well.
+ */
+ if (idx >= shp->shm_npages) {
+ return NULL;
+ }
down(&shp->sem);
if(shp != shm_lock(shp->id))
BUG();