bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug#129559: libpager robustness


From: Marcus Brinkmann
Subject: Bug#129559: libpager robustness
Date: Wed, 16 Jan 2002 20:25:24 +0100
User-agent: Mutt/1.3.25i

Package: hurd
Version: n/a

Hi,

Neal reported this bug to me a while ago.  If you send an invalid message (a
message with an unhandled msgid) to a pager, it will miss out on this msg id
and the seqno stuff doesn't catch up anymore.  The result is a deadlock
waiting for this msg id when the next valid message is processed.

Neal and me agreed on a potential fix for this, the patch is below.  The
only thing I am uncertain about is what checks need to be done on the msg
format.  Does the kernel guarantee that the header up to msgh_remote_port
really exists and is valid?  I'd guess so much, but I didn't verify it.

2001-01-16  Marcus Brinkmann <marcus@gnu.org>

        * demuxer.c (pager_demuxer): If the message was not accepted by one
        of the servers, acquire a reference to the pager and its lock, and
        wait until all previous messages have been processed.  This makes
        sure that the next message that arrives can proceed.
        Reported by Neal H Walfield <neal@cs.uml.edu>

Index: demuxer.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libpager/demuxer.c,v
retrieving revision 1.8
diff -u -p -r1.8 demuxer.c
--- demuxer.c   20 Jun 1995 16:56:05 -0000      1.8
+++ demuxer.c   16 Jan 2002 19:17:12 -0000
@@ -20,7 +20,7 @@
 #include "notify_S.h"
 
 /* Demultiplex a single message directed at a pager port; INP is the
-   message received; fille OUTP with the reply.  */
+   message received; fill OUTP with the reply.  */
 int
 pager_demuxer (mach_msg_header_t *inp,
               mach_msg_header_t *outp)
@@ -30,7 +30,24 @@ pager_demuxer (mach_msg_header_t *inp,
   extern int _pager_seqnos_notify_server (mach_msg_header_t *inp,
                                          mach_msg_header_t *outp);
   
-  return (_pager_seqnos_memory_object_server (inp, outp)
-         || _pager_seqnos_notify_server (inp, outp));
+  int result = _pager_seqnos_memory_object_server (inp, outp)
+    || _pager_seqnos_notify_server (inp, outp);
+  if (!result)
+    {
+      struct pager *p;
+
+      p = ports_lookup_port (0, inp->msgh_remote_port, _pager_class);
+      if (p)
+       {
+         mutex_lock (&p->interlock);
+         _pager_wait_for_seqno (p, seqno);
+         _pager_release_seqno (p, seqno);
+         mutex_unlock (&p->interlock);
+         ports_port_deref (p);
+       }
+    }
+  return result;
 }
+
+
 


-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]