From owner-freebsd-current Tue Dec 12 14:43:53 2000 From owner-freebsd-current@FreeBSD.ORG Tue Dec 12 14:43:50 2000 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from email_server.midstream.com (unknown [63.113.115.195]) by hub.freebsd.org (Postfix) with ESMTP id 32D7537B400 for ; Tue, 12 Dec 2000 14:43:50 -0800 (PST) Received: by EMAIL_SERVER with Internet Mail Service (5.5.2650.21) id ; Tue, 12 Dec 2000 14:45:45 -0800 Message-ID: <31E4B6337A4FD411BD45000102472E0C05E6FD@EMAIL_SERVER> From: Jeff Roberson To: "'freebsd-current@freebsd.org'" Subject: Bug Fix for SYSV semaphores. Date: Tue, 12 Dec 2000 14:45:37 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C0648D.4319C7E0" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0648D.4319C7E0 Content-Type: text/plain; charset="iso-8859-1" I noticed that sysv semaphores initialize the otime member of the semid_ds structure to 0, but they never update it afterwards. This field is supposed to be the last operation time. ie the last time a semctl was done. In UNIX Network Programming, Stevens suggests using this variable to detect races between multiple processes creating/accessing a sysv semaphore. Anyway, I looked through the code and came up with the following trivial patch. Could some one review it and perhaps commit it? This patch was made against current, but I noticed the bug is there in 4.1.1 and most likely everything before that. Thanks, Jeff (Pardon the revision numbers, they are from my own repository) *** sysv_sem.c 2000/09/15 11:11:48 1.1.1.1 --- sysv_sem.c 2000/12/12 23:44:28 *************** *** 543,548 **** --- 543,550 ---- return(EINVAL); } + semaptr->sem_otime = time_second; + if (eval == 0) p->p_retval[0] = rval; return(eval); ------_=_NextPart_001_01C0648D.4319C7E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Bug Fix for SYSV semaphores.

I noticed that sysv semaphores initialize the otime = member of the semid_ds structure to 0, but they never update it = afterwards.  This field is supposed to be the last operation = time.  ie the last time a semctl was done.  In UNIX Network = Programming, Stevens suggests using this variable to detect races = between multiple processes creating/accessing a sysv semaphore.  = Anyway, I looked through the code and came up with the following = trivial patch.  Could some one review it and perhaps commit = it?  This patch was made against current, but I noticed the bug is = there in 4.1.1 and most likely everything before that.

Thanks,
Jeff

(Pardon the revision numbers, they are from my own = repository)

*** sysv_sem.c  2000/09/15 = 11:11:48     1.1.1.1
--- sysv_sem.c  2000/12/12 23:44:28
***************
*** 543,548 ****
--- 543,550 ----
          &nb= sp;     return(EINVAL);
        }
 
+       = semaptr->sem_otime =3D time_second;
+
        if (eval = =3D=3D 0)
          &nb= sp;     p->p_retval[0] =3D rval;
        = return(eval);

------_=_NextPart_001_01C0648D.4319C7E0-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message