Skip to content

Commit

Permalink
Cap shmmax at INT_MAX in compat shminfo
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Guy Streeter <streeter@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Guy Streeter authored and Linus Torvalds committed May 8, 2007
1 parent ee527cd commit af7c693
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ipc/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit af7c693

Please sign in to comment.