]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - ipc/shm.c
ipc/shm.c: check for overflows of shm_tot
[karo-tx-linux.git] / ipc / shm.c
index dda8f1ff3c352105f1e1549ac6e3971ef0425251..9e51bf24634463d5ec0e493a6888173d57ac7b0a 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -493,7 +493,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
        if (size < SHMMIN || size > ns->shm_ctlmax)
                return -EINVAL;
 
-       if (ns->shm_tot + numpages > ns->shm_ctlall)
+       if (ns->shm_tot + numpages < ns->shm_tot ||
+                       ns->shm_tot + numpages > ns->shm_ctlall)
                return -ENOSPC;
 
        shp = ipc_rcu_alloc(sizeof(*shp));