aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2014-06-06 17:37:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:08:14 -0400
commit1376327ce1f790070ec7128b285e2d8965e760a5 (patch)
tree6d6c8b14231b487e476e0aa84775173be45ff455 /ipc
parent09c6eb1f651dad601f02435bbd79734954960c42 (diff)
ipc/shm.c: check for integer overflow during shmget.
SHMMAX is the upper limit for the size of a shared memory segment, counted in bytes. The actual allocation is that size, rounded up to the next full page. Add a check that prevents the creation of segments where the rounded up size causes an integer overflow. Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Acked-by: Davidlohr Bueso <davidlohr@hp.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: Michael Kerrisk <mtk.manpages@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/shm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 9e51bf246344..89fc354156cb 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -493,6 +493,9 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
493 if (size < SHMMIN || size > ns->shm_ctlmax) 493 if (size < SHMMIN || size > ns->shm_ctlmax)
494 return -EINVAL; 494 return -EINVAL;
495 495
496 if (numpages << PAGE_SHIFT < size)
497 return -ENOSPC;
498
496 if (ns->shm_tot + numpages < ns->shm_tot || 499 if (ns->shm_tot + numpages < ns->shm_tot ||
497 ns->shm_tot + numpages > ns->shm_ctlall) 500 ns->shm_tot + numpages > ns->shm_ctlall)
498 return -ENOSPC; 501 return -ENOSPC;