1
0
Fork 0
alistair23-linux/ipc
Pavel Emelianov 7be77e20d5 Fix user struct leakage with locked IPC shem segment
When user locks an ipc shmem segmant with SHM_LOCK ctl and the segment is
already locked the shmem_lock() function returns 0.  After this the
subsequent code leaks the existing user struct:

== ipc/shm.c: sys_shmctl() ==
     ...
     err = shmem_lock(shp->shm_file, 1, user);
     if (!err) {
          shp->shm_perm.mode |= SHM_LOCKED;
          shp->mlock_user = user;
     }
     ...
==

Other results of this are:
1. the new shp->mlock_user is not get-ed and will point to freed
   memory when the task dies.
2. the RLIMIT_MEMLOCK is screwed on both user structs.

The exploit looks like this:

==
    id = shmget(...);
    setresuid(uid, 0, 0);
    shmctl(id, SHM_LOCK, NULL);
    setresuid(uid + 1, 0, 0);
    shmctl(id, SHM_LOCK, NULL);
==

My solution is to return 0 to the userspace and do not change the
segment's user.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-31 15:39:40 -07:00
..
Makefile [PATCH] sysctl: move SYSV IPC sysctls to their own file 2007-02-14 08:09:59 -08:00
compat.c fix logic error in ipc compat semctl() 2007-07-06 10:23:43 -07:00
compat_mq.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipc_sysctl.c [PATCH] sysctl: remove insert_at_head from register_sysctl 2007-02-14 08:09:59 -08:00
mqueue.c mm: Remove slab destructors from kmem_cache_create(). 2007-07-20 10:11:58 +09:00
msg.c arch/i386/* fs/* ipc/*: mark variables with uninitialized_var() 2007-07-17 16:23:19 -04:00
msgutil.c [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
sem.c arch/i386/* fs/* ipc/*: mark variables with uninitialized_var() 2007-07-17 16:23:19 -04:00
shm.c Fix user struct leakage with locked IPC shem segment 2007-07-31 15:39:40 -07:00
util.c remove CONFIG_UTS_NS and CONFIG_IPC_NS 2007-07-16 09:05:47 -07:00
util.h remove CONFIG_UTS_NS and CONFIG_IPC_NS 2007-07-16 09:05:47 -07:00