Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!gymble!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: A problem with kernel buffers (struct buf). Message-ID: <1423@umcp-cs.UUCP> Date: Wed, 28-Aug-85 12:14:09 EDT Article-I.D.: umcp-cs.1423 Posted: Wed Aug 28 12:14:09 1985 Date-Received: Thu, 29-Aug-85 08:46:52 EDT References: <318@ucsbcsl.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 53 >In the work on the 4.2BSD kernel that I have been doing recently, I >have come across a problem that I do not understand. ... I allocate >a buffer with geteblk with a size of about 10k, Say no more! That is the problem. You cannot allocate a buffer larger than MAXBSIZE without incurring "mysterious problems", since each buffer has a virtual memory space of MAXBSIZE bytes (note that for this reason MAXBSIZE must be a multiple of CLBYTES). Had you installed my mass driver---or had Berkeley put a firewall in allocbuf in the first place---you would have found the problem much earlier. Don't be embarrassed, though; I did the same thing the first time in the mass driver, thus the following fix. For those of you who don't want to install the whole thing, here's just the changes to sys/vax/ufs_machdep.c. Your line numbers may vary: *** /tmp/,RCSt1004349 Wed Aug 28 12:10:44 1985 --- /tmp/,RCSt2004349 Wed Aug 28 12:10:45 1985 *************** *** 29,32 sizealloc = roundup(size, CLBYTES); /* * Buffer size does not change --- 28,34 ----- sizealloc = roundup(size, CLBYTES); + if (sizealloc > MAXBSIZE) + panic("allocbuf"); + /* * Buffer size does not change *************** *** 68,72 &tp->b_un.b_addr[tp->b_bufsize], take); tp->b_bufsize += take; ! bp->b_bufsize = bp->b_bufsize - take; if (bp->b_bcount > bp->b_bufsize) bp->b_bcount = bp->b_bufsize; --- 70,74 ----- &tp->b_un.b_addr[tp->b_bufsize], take); tp->b_bufsize += take; ! bp->b_bufsize -= take; if (bp->b_bcount > bp->b_bufsize) bp->b_bcount = bp->b_bufsize; -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland