All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipc 3/3 enforce SEMVMX limit for undo
@ 2004-07-03 17:44 Manfred Spraul
  0 siblings, 0 replies; only message in thread
From: Manfred Spraul @ 2004-07-03 17:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

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>

[-- Attachment #2: patch-ipc-03-semval --]
[-- Type: text/plain, Size: 847 bytes --]

--- 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;
 			}
 		}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-07-03 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-03 17:44 [PATCH] ipc 3/3 enforce SEMVMX limit for undo Manfred Spraul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.