lkml.org 
[lkml]   [2004]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 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 <manfred@colorfullife.com>
--- 2.6/ipc/sem.c 2004-07-03 18:15:25.555921328 +0200
+++ build-2.6/ipc/sem.c 2004-07-03 17:40:02.511673112 +0200
@@ -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 <manfred@colorfullife.com>
+ */
if (sem->semval < 0)
- sem->semval = 0; /* shouldn't happen */
+ sem->semval = 0;
+ if (sem->semval > SEMVMX)
+ sem->semval = SEMVMX;
sem->sempid = current->tgid;
}
}
\
 
 \ /
  Last update: 2005-03-22 14:04    [W:0.249 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site