ipc 3/3 enforce SEMVMX limit for undo
PATCH 1/1 ipc 3/3 enforce SEMVMX limit for undo
Hi,
Independant 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.
Andrew - could you add it to -mm?
Signed-off-by Manfred Spraul <[email protected]>
ipc/sem.c +16 -1
@@ -1263,8 +1263,23 @@struct sem * sem = &sma->sem_base[i];if (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 <[email protected]> +*/ if (sem->semval <0 ) - sem->semval =0 ;/* shouldn't happen */ + sem->semval =0 ; +if (sem->semval >SEMVMX ) + sem->semval =SEMVMX ; sem->sempid = current->tgid; } }