Commit 8dd459f2 authored by Manfred Spraul's avatar Manfred Spraul Committed by Linus Torvalds

[PATCH] ipc: enforce SEMVMX limit for undo

Independent from the other patches:

undo operations should not result in out of range semaphore values.  The test
for newval > SEMVMX is missing.  The attached patch adds the test and a
comment.
Signed-Off-By: default avatarManfred Spraul <manfred@colorfullife.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 208b201a
...@@ -1286,8 +1286,23 @@ void exit_sem(struct task_struct *tsk) ...@@ -1286,8 +1286,23 @@ void exit_sem(struct task_struct *tsk)
struct sem * sem = &sma->sem_base[i]; struct sem * sem = &sma->sem_base[i];
if (u->semadj[i]) { if (u->semadj[i]) {
sem->semval += u->semadj[i]; sem->semval += u->semadj[i];
/*
* Range checks of the new semaphore value,
* not defined by sus:
* - Some unices ignore the undo entirely
* (e.g. HP UX 11i 11.22, Tru64 V5.1)
* - some cap the value (e.g. FreeBSD caps
* at 0, but doesn't enforce SEMVMX)
*
* Linux caps the semaphore value, both at 0
* and at SEMVMX.
*
* Manfred <manfred@colorfullife.com>
*/
if (sem->semval < 0) if (sem->semval < 0)
sem->semval = 0; /* shouldn't happen */ sem->semval = 0;
if (sem->semval > SEMVMX)
sem->semval = SEMVMX;
sem->sempid = current->tgid; sem->sempid = current->tgid;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment