Return to BSD News archive
Newsgroups: comp.bugs.2bsd Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!nntp.coast.net!news-peer.gsl.net!news.gsl.net!news.sprintlink.net!news-peer.sprintlink.net!news.mathworks.com!uunet!in3.uu.net!news.new-york.net!wlbr!moe.2bsd.com!sms From: sms@moe.2bsd.com (Steven M. Schultz) Subject: using ftruncate(2) to extend file panics kernel (#332) Organization: 2BSD, Simi Valley CA USA Message-ID: <DyKxJL.Lnv@moe.2bsd.com> Date: Tue, 1 Oct 1996 04:23:45 GMT Lines: 100 Subject: using ftruncate(2) to extend file panics kernel (#332) Index: sys/ufs_inode.c 2.11BSD Description: ftruncate(2) can, beginning with update #331, extend a file as well as shrink a file. Alas a bug was introduced in the file extension code. Using ftruncate(2) to extend a file can panic the system. Repeat-By: Run quotacheck(8). quotacheck(8) issues a ftruncate(2) against the quota file in order to set the size - if this results in the file needing to grow then a kernel panic _may_ result. Fix: Rather than repackage #331 this is being issued separately. The problem is twofold: an unnecessary 'bdwrite(bp)' call and 'bp' being uninitialized. The 'bdwrite' being issued during a file extension is completely unnecessary because "bmap()" has already allocated and written the required block (clearing the buffer first if necessary). The panic may or may not happen depending on the uninitialized content of 'bp' on the stack. Cut where indicated, saving to a file (/tmp/332) and then: patch -p0 < /tmp/332 cd /sys/YOUR_KERNEL make mv /unix /ounix mv /netnix /onetnix mv unix netnix / chmod 744 /unix /netnix make clean reboot It's a good idea (especially with a bug like this) to update the GENERIC kernel as well and keep it installed in /genunix: cd /sys/GENERIC make mv unix /genunix chmod 744 /genunix make clean The "make clean" commands are *optional*. While keeping objects around shortens kernel build times there is a risk of dependencies (especially with options specified by '-D' lines in the Makefile) not being detected and corrupt kernels being built in the future. This and previous updates are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD --------------------------cut here----------------------- *** /sys/sys/ufs_inode.c.old Sat Sep 28 20:39:29 1996 --- /sys/sys/ufs_inode.c Mon Sep 30 13:25:45 1996 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_inode.c 1.5 (2.11BSD GTE) 1996/9/19 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_inode.c 1.6 (2.11BSD GTE) 1996/9/30 */ #include "param.h" *************** *** 474,480 **** bytesreleased = oip->i_size - length; #endif oip->i_size = length; - bdwrite(bp); goto doquotaupd; } --- 474,479 ---- *** /VERSION.old Sat Sep 28 20:40:03 1996 --- /VERSION Mon Sep 30 13:24:16 1996 *************** *** 1,4 **** ! Current Patch Level: 331 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 332 2.11 BSD ============