Subject: bin/6247: lfs_cleanerd overflows char register counting live bytes
To: None <gnats-bugs@gnats.netbsd.org, perseant@hhhh.org, margo@eecs.harvard.edu>
From: None <perseant@hhhh.org>
List: netbsd-bugs
Date: 10/04/1998 15:46:54
>Number:         6247
>Category:       bin
>Synopsis:       lfs_cleanerd tries to store byte counts up to 1M in a char
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  4 15:50:02 1998
>Last-Modified:
>Originator:     Konrad Schroder
>Organization:
-------------------------------------------------------------------------
Konrad Schroder           http://www.hitl.washington.edu/people/perseant/
System Administrator                         perseant@hitl.washington.edu
Human Interface Technology Lab                     Voice: +1.206.616.1478
Box 352142, University of Washington, 98195, USA     FAX: +1.206.543.5380
>Release:        Sep 14, 1998
>Environment:
System: NetBSD inle 1.3 NetBSD 1.3 (INLE) #1: Sun Apr 19 15:01:29 PDT 1998 perseant@gro:/usr/src/sys/arch/i386/compile/INLE i386

>Description:
        When run with the -b flag, lfs_cleanerd uses the "live byte"
        count in the segment use table to determine which segment will
        result in the most cleaning for the effort.  This count used to
        be "live blocks", and it was stored in a char (since
        summary_size * block_size = 512 * 4096 > 1M = segment_size), 
        but now it requires a little bit larger storage.
>How-To-Repeat:
        newlfs -L /dev/rsd0g
        mount -t lfs -o-n /dev/sd0g /mnt
        /usr/libexec/lfs_cleanerd -b -d /mnt
        (do something on /mnt that creates & deletes files)
        
        You will notice that the cleanerd reports either "(0 bytes)" or
        "(-128 bytes)".
>Fix:

*** lfs_cleanerd.1.3H/cleanerd.c	Sat Sep 26 14:20:51 1998
--- lfs_cleanerd/cleanerd.c	Sun Oct  4 13:58:11 1998
***************
*** 75,81 ****
  struct seglist { 
  	int sl_id;	/* segment number */
  	int sl_cost; 	/* cleaning cost */
! 	char sl_bytes;	/* bytets in segment */
  };
  
  struct tossstruct {
--- 78,84 ----
  struct seglist { 
  	int sl_id;	/* segment number */
  	int sl_cost; 	/* cleaning cost */
! 	int sl_bytes;	/* bytes in segment */
  };
  
  struct tossstruct {
>Audit-Trail:
>Unformatted: