Skip to contentSkip to conversation

Cap shmmax at INT_MAX in compat shminfo

PATCH New Guy Streeter 1 participant 1 message Feb 27, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cap shmmax at INT_MAX in compat shminfo

The value of shmmax may be larger than will fit in the struct used by the 32bit compat version of sys_shmctl. This change mirrors what the normal sys_shmctl does when called with the old IPC_INFO command.

---
 ipc/compat.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
ipc/compat.c +4 -0
index fa18141..8b44aa9 100644
@@ -542,6 +542,8 @@ static inline int put_compat_shminfo64(struct shminfo64 *smi,
 
 	if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64)))
 		return -EFAULT;
+	if (smi->shmmax > INT_MAX)
+		smi->shmmax = INT_MAX;
 	err  = __put_user(smi->shmmax, &up64->shmmax);
 	err |= __put_user(smi->shmmin, &up64->shmmin);
 	err |= __put_user(smi->shmmni, &up64->shmmni);
@@ -557,6 +559,8 @@ static inline int put_compat_shminfo(struct shminfo64 *smi,
 
 	if (!access_ok(VERIFY_WRITE, up, sizeof(*up)))
 		return -EFAULT;
+	if (smi->shmmax > INT_MAX)
+		smi->shmmax = INT_MAX;
 	err  = __put_user(smi->shmmax, &up->shmmax);
 	err |= __put_user(smi->shmmin, &up->shmmin);
 	err |= __put_user(smi->shmmni, &up->shmmni);
Signature · 1 line
1.4.4.2