home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / bsd / 4901 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.4 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!tools!ws
  2. From: ws@tools.de (Wolfgang Solfrank)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Bug in mbuf allocation
  5. Date: 31 Aug 92 13:32:39
  6. Organization: TooLs GmbH, Bonn, Germany
  7. Lines: 137
  8. Message-ID: <WS.92Aug31133239@kurt.tools.de>
  9. NNTP-Posting-Host: kurt.tools.de
  10.  
  11. BUG FINDER INFORMATION
  12.  
  13. NAME:    Wolfgang Solfrank
  14. FIRM:    TooLs GmbH
  15. ADDRESS: Adolfstr. 5, D-W5300 Bonn 1
  16. COUNTRY: Germany
  17. PHONE:    +49 228 985800
  18. FAX:    +49 228 697543
  19. EMAIL:    ws@tools.de
  20.  
  21. There is a bug in the mbuf allocation code.
  22.  
  23. While the flags in sys/mbuf.h define M_DONTWAIT and M_WAIT in terms of
  24. M_NOWAIT and M_WAITOK, these flags are only used for the kernel malloc.
  25. But the actual code in kern/uipc_mbuf.h uses kmem_malloc, which has
  26. only a parameter canwait. To stick with Murphy's law :-) this parameter
  27. has just the opposite meaning from the flag values above.
  28. This may result in occasional hangs of the system (if mbuf allocation
  29. with M_DONTWAIT is called which may result in a wait) or panics or other
  30. nasty things (if called with M_WAIT which may return a NULL pointer
  31. that is not expected and as such not tested by the calling code).
  32.  
  33. For the moment I have fixed the relevant parts in uipc_mbuf.c (fix
  34. included below), but the real fix would probably require a change
  35. in the last parameter to kmem_malloc to get in line with the
  36. parameter to malloc.
  37. --
  38. ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
  39.  
  40. --------------- cut --------------- cut --------------- cut ---------------
  41. *** uipc_mbuf.c    Sat Jul 18 18:29:56 1992
  42. --- /home/kurt/bsd/bsd/sys/kern/uipc_mbuf.c    Mon Aug 31 13:18:39 1992
  43. ***************
  44. *** 71,78 ****
  45.    * and place on cluster free list.
  46.    * Must be called at splimp.
  47.    */
  48. ! /* ARGSUSED */
  49. ! m_clalloc(ncl, canwait)
  50.       register int ncl;
  51.   {
  52.       int npg, mbx;
  53. --- 71,77 ----
  54.    * and place on cluster free list.
  55.    * Must be called at splimp.
  56.    */
  57. ! m_clalloc(ncl, how)
  58.       register int ncl;
  59.   {
  60.       int npg, mbx;
  61. ***************
  62. *** 81,87 ****
  63.       static int logged;
  64.   
  65.       npg = ncl * CLSIZE;
  66. !     p = (caddr_t)kmem_malloc(mb_map, ctob(npg), canwait);
  67.       if (p == NULL) {
  68.           if (logged == 0) {
  69.               logged++;
  70. --- 80,86 ----
  71.       static int logged;
  72.   
  73.       npg = ncl * CLSIZE;
  74. !     p = (caddr_t)kmem_malloc(mb_map, ctob(npg), !(how&M_DONTWAIT));
  75.       if (p == NULL) {
  76.           if (logged == 0) {
  77.               logged++;
  78. ***************
  79. *** 153,184 ****
  80.    * for critical paths.
  81.    */
  82.   struct mbuf *
  83. ! m_get(canwait, type)
  84. !     int canwait, type;
  85.   {
  86.       register struct mbuf *m;
  87.   
  88. !     MGET(m, canwait, type);
  89.       return (m);
  90.   }
  91.   
  92.   struct mbuf *
  93. ! m_gethdr(canwait, type)
  94. !     int canwait, type;
  95.   {
  96.       register struct mbuf *m;
  97.   
  98. !     MGETHDR(m, canwait, type);
  99.       return (m);
  100.   }
  101.   
  102.   struct mbuf *
  103. ! m_getclr(canwait, type)
  104. !     int canwait, type;
  105.   {
  106.       register struct mbuf *m;
  107.   
  108. !     MGET(m, canwait, type);
  109.       if (m == 0)
  110.           return (0);
  111.       bzero(mtod(m, caddr_t), MLEN);
  112. --- 152,183 ----
  113.    * for critical paths.
  114.    */
  115.   struct mbuf *
  116. ! m_get(how, type)
  117. !     int how, type;
  118.   {
  119.       register struct mbuf *m;
  120.   
  121. !     MGET(m, how, type);
  122.       return (m);
  123.   }
  124.   
  125.   struct mbuf *
  126. ! m_gethdr(how, type)
  127. !     int how, type;
  128.   {
  129.       register struct mbuf *m;
  130.   
  131. !     MGETHDR(m, how, type);
  132.       return (m);
  133.   }
  134.   
  135.   struct mbuf *
  136. ! m_getclr(how, type)
  137. !     int how, type;
  138.   {
  139.       register struct mbuf *m;
  140.   
  141. !     MGET(m, how, type);
  142.       if (m == 0)
  143.           return (0);
  144.       bzero(mtod(m, caddr_t), MLEN);
  145. --------------- cut --------------- cut --------------- cut ---------------
  146. --
  147. ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
  148.