From owner-cvs-all Sat Jul 4 22:06:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA21919 for cvs-all-outgoing; Sat, 4 Jul 1998 22:06:08 -0700 (PDT) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from freebie.lemis.com (freebie.lemis.com [139.130.136.133] (may be forged)) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA21914; Sat, 4 Jul 1998 22:06:02 -0700 (PDT) (envelope-from grog@freebie.lemis.com) Received: (from grog@localhost) by freebie.lemis.com (8.9.0/8.9.0) id OAA09856; Sun, 5 Jul 1998 14:35:41 +0930 (CST) Message-ID: <19980705143540.B18970@freebie.lemis.com> Date: Sun, 5 Jul 1998 14:35:40 +0930 From: Greg Lehey To: Bruce Evans , cvs-committers@FreeBSD.ORG, julian@FreeBSD.ORG Subject: Don't malloc buf headers (was: cvs commit: src/sys/dev/vn vn.c) References: <199807040841.SAA31111@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i In-Reply-To: <199807040841.SAA31111@godzilla.zeta.org.au>; from Bruce Evans on Sat, Jul 04, 1998 at 06:41:17PM +1000 WWW-Home-Page: http://www.lemis.com/~grog Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk On Saturday, 4 July 1998 at 18:41:17 +1000, Bruce Evans wrote: >> Modified files: >> sys/dev/vn vn.c >> Log: >> Don't use a struct buf (malloc'd) without first initialising all the fields >> to some known value! >> (probable cause of soft updates exploding with vn devices) > > Buffers should never be malloced. This is a problem that has been concerning me for a while, and one that we have discussed before. In vinum, I need a buffer structure with some pointers to other structures internal to vinum. We've already agreed that b_driver1 and b_driver2 aren't the way to go (though I notice that they're still present). My solution, stolen from ccd, has been to malloc my own super-bufs with additional fields at the end. If this isn't kosher, what method should I use? > There is no way of knowing how to initialize new fields like b_dep. Well, I've just checked through the code, and I can see how to initialize it (for example, LIST_INIT(&cbp->cb_buf.b_dep) in ccd, in conjunction with a malloced buffer :-), but I can't see it being used. I can't find anywhere in the sources where it is actually more than initialized. I also can't remember seeing anything about it in the commit messages, and the CVS log for buf.h doesn't mention it. If I read the diffs right, it appears to have come from the softupdates code. What's it for? Should I worry in the vinum code, where the buffers are all internal and have no file system connections? Greg -- See complete headers for address and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message