This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Subtle FreeBSD TCP/IP stack macro bug


       Hello,

Found in FreeBSD's CVS (via NetBSD): 

  "Fix a bug in sblock() that has existed since revision 1.1 from BSD:
   correctly return an error if M_NOWAIT is passed to sblock() and the
   operation might block. This remarkably subtle macro bug appears to be
   responsible for quite a few undiagnosed socket buffer corruption and
   mbuf-related kernel panics."


diff --git a/net/bsd_tcpip/current/ChangeLog b/net/bsd_tcpip/current/ChangeLog
--- a/net/bsd_tcpip/current/ChangeLog
+++ b/net/bsd_tcpip/current/ChangeLog
@@ -1,3 +1,10 @@ 2007-07-08  Alexander Aganichev <aaganic
+2007-09-11  Daniel Néri  <daniel.neri@sigicom.se>
+
+	* include/sys/socketvar.h: Fix very old and subtle macro bug. From
+	FreeBSD revision 1.141.2.3 (RELENG_6 branch): "correctly return an
+	error if M_NOWAIT is passed to sblock() and the operation might
+	block."
+
 2007-07-08  Alexander Aganichev <aaganichev@gmail.com>
 
 	* include/sys/param.h (log_): Really disable logging when
diff --git a/net/bsd_tcpip/current/include/sys/socketvar.h b/net/bsd_tcpip/current/include/sys/socketvar.h
--- a/net/bsd_tcpip/current/include/sys/socketvar.h
+++ b/net/bsd_tcpip/current/include/sys/socketvar.h
@@ -253,7 +253,7 @@ struct	xsocket {
  */
 #define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
 		(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
-		((sb)->sb_flags |= SB_LOCK), 0)
+		((sb)->sb_flags |= SB_LOCK, 0))
 
 /* release lock on sockbuf sb */
 #define	sbunlock(sb) { \

Regards,
-- 
Daniel Néri <daniel.neri@sigicom.se>
Sigicom AB, Stockholm, Sweden

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]