Date: Tue, 12 Dec 2000 14:45:37 -0800 From: Jeff Roberson <jeff@midstream.com> To: "'freebsd-current@freebsd.org'" <freebsd-current@freebsd.org> Subject: Bug Fix for SYSV semaphores. Message-ID: <31E4B6337A4FD411BD45000102472E0C05E6FD@EMAIL_SERVER>
next in thread | raw e-mail | index | archive | help
[-- Attachment #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);
[-- Attachment #2 --]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>Bug Fix for SYSV semaphores.</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>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.</FONT></P>
<P><FONT SIZE=2>Thanks,</FONT>
<BR><FONT SIZE=2>Jeff</FONT>
</P>
<P><FONT SIZE=2>(Pardon the revision numbers, they are from my own repository)</FONT>
</P>
<P><FONT SIZE=2>*** sysv_sem.c 2000/09/15 11:11:48 1.1.1.1</FONT>
<BR><FONT SIZE=2>--- sysv_sem.c 2000/12/12 23:44:28</FONT>
<BR><FONT SIZE=2>***************</FONT>
<BR><FONT SIZE=2>*** 543,548 ****</FONT>
<BR><FONT SIZE=2>--- 543,550 ----</FONT>
<BR><FONT SIZE=2> return(EINVAL);</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>+ semaptr->sem_otime = time_second;</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> if (eval == 0)</FONT>
<BR><FONT SIZE=2> p->p_retval[0] = rval;</FONT>
<BR><FONT SIZE=2> return(eval);</FONT>
</P>
</BODY>
</HTML>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?31E4B6337A4FD411BD45000102472E0C05E6FD>
