Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

user/3322: vmstat, iostat, etc. fail on a diskless machine

From: <amh(at)POBOX.COM>
Date: Tue Jun 17 2003 - 21:53:14 EDT


>Number: 3322
>Category: user
>Synopsis: vmstat, iostat, etc. fail on a diskless machine
>Confidential: no
net
>Environment:

	System      : OpenBSD 3.3
	Architecture: OpenBSD.sparc
	Machine     : SPARCstation LX (sun4m)

>Description:

I first noticed this problem while using a SPARCstation LX running diskless. I can provide configuration information for this setup if needed, but aside from the problem detailed here, everything seems to work fine, so I'm not sure that would be useful.

It seems that vmstat, iostat, systat, and possibly other utilities do not deal gracefully with the case of a machine having no disks. They segfault immediately without any diagnostic information. (and systat b0rks your terminal as a bonus prize)

I compiled vmstat with debugging information (cc -g) and performed a stack backtrace. I think the problem arises in dkinit() when the kernel is interrogated via sysctl to obtain the disk names. It seems that there's no error checking for the case when cur.dk_ndrive (hw.diskcount) is 0, and this value is used to size the memory allocations later on in dkinit(). calloc() gives us a protected zero size object for cur.dk_name, and at line 479, boom.

danube$ /usr/obj/usr.bin/vmstat/vmstat
Segmentation fault (core dumped)
danube$ gdb /usr/obj/usr.bin/vmstat/vmstat vmstat.core GNU gdb 4.16.1
Copyright 1996 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-unknown-openbsd3.3"... Core was generated by `vmstat'.
Program terminated with signal 11, Segmentation fault.

Reading symbols from /usr/lib/libkvm.so.7.0...done.
Reading symbols from /usr/lib/libc.so.29.0...done.
Reading symbols from /usr/libexec/ld.so...done.
#0  0x11db0 in dkinit (select=0) at /usr/src/usr.bin/vmstat/dkstats.c:479
479                         cur.dk_name[i] = name;
(gdb) bt
#0 0x11db0 in dkinit (select=0) at /usr/src/usr.bin/vmstat/dkstats.c:479 #1 0x122c3 in main (argc=1, argv=0xf7fff928)

    at /usr/src/usr.bin/vmstat/vmstat.c:259 #2 0x10d27 in ___start ()
(gdb)

>How-To-Repeat:

Set up a diskless machine, boot, run the mentioned commands.
>Fix:

I believe I have found the offending code in vmstat, but my analysis could be wrong. And anyway, I do not know what the best fix would be. Or perhaps the NFS mounts should be counting as "disks" and something is wrong in my environment somehow? In any event I think this case/error should be handled more gracefully.

>Release-Note:
Received on Tue Jun 17 22:25:09 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:58 EDT

Do you need help?X

Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library