*BSD News Article 7624


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!sun-barr!cs.utexas.edu!uwm.edu!ogicse!news.u.washington.edu!ns1.nodak.edu!plains.NoDak.edu!tinguely
From: tinguely@plains.NoDak.edu (Mark Tinguely)
Newsgroups: comp.unix.bsd
Subject: Small buffer leak in kern__physio.c
Message-ID: <BxGz47.9w8@ns1.nodak.edu>
Date: 9 Nov 92 22:14:31 GMT
Article-I.D.: ns1.BxGz47.9w8
Sender: usenet@ns1.nodak.edu (News login)
Organization: North Dakota State University
Lines: 38
Nntp-Posting-Host: plains.nodak.edu


 There appears to be a small buffer leak in kern__physio.c. The function
 physio() allocates a buf only for the lifetime of that function. If the
 function exits on access error, the buf is not released.

 This error was found while looking for M_TEMP allocation (ie. may not be the
 direct cause of a known problem). This is fix visible fix. physio() is
 not called that often to cause a major memory loss.

*** kern__physio.c.orig	Mon Nov  9 15:49:10 1992
--- kern__physio.c	Mon Nov  9 15:53:02 1992
***************
*** 117,126 ****
  		bp->b_bcount = min (256*1024, amttodo);
  
  		/* first, check if accessible */
! 		if (rw == B_READ && !useracc(base, bp->b_bcount, B_WRITE))
  			return (EFAULT);
! 		if (rw == B_WRITE && !useracc(base, bp->b_bcount, B_READ))
  			return (EFAULT);
  
  		/* update referenced and dirty bits, handle copy objects */
  		if (rw == B_READ)
--- 117,130 ----
  		bp->b_bcount = min (256*1024, amttodo);
  
  		/* first, check if accessible */
! 		if (rw == B_READ && !useracc(base, bp->b_bcount, B_WRITE)) {
! 			free(bp, M_TEMP);
  			return (EFAULT);
! 		}
! 		if (rw == B_WRITE && !useracc(base, bp->b_bcount, B_READ)) {
! 			free(bp, M_TEMP);
  			return (EFAULT);
+ 		}
  
  		/* update referenced and dirty bits, handle copy objects */
  		if (rw == B_READ)