Apply by doing:
        cd /usr/src
        patch -p0 < 003_sysvsem.patch

And then rebuild your kenel and reboot, e.g.
        cd sys/arch/`machine`/conf
        config GENERIC
        cd ../compile/GENERIC
        make depend bsd
        mv /bsd /bsd.old
        cp bsd /
        reboot

Index: sys/kern/sysv_sem.c
===================================================================
RCS file: /cvs/src/sys/kern/sysv_sem.c,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -r1.16.2.1 -r1.16.2.2
--- sys/kern/sysv_sem.c	20 Aug 2003 20:16:41 -0000	1.16.2.1
+++ sys/kern/sysv_sem.c	10 Sep 2003 15:38:01 -0000	1.16.2.2
@@ -893,7 +893,7 @@
 		if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &val)) ||
 		    val == seminfo.semmns)
 			return (error);
-		if (val < seminfo.semmns)
+		if (val < seminfo.semmns || val > 0xffff)
 			return (EINVAL);	/* can't decrease semmns */
 		seminfo.semmns = val;
 		return (0);
@@ -911,7 +911,7 @@
 		if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &val)) ||
 		    val == seminfo.semmsl)
 			return (error);
-		if (val < seminfo.semmsl)
+		if (val < seminfo.semmsl || val > 0xffff)
 			return (EINVAL);	/* can't decrease semmsl */
 		seminfo.semmsl = val;
 		return (0);
