Subject: apparent bug in iostats
To: None <tech-kern@netbsd.org>
From: Bucky Katz <bucky@picovex.com>
List: tech-kern
Date: 08/22/2006 16:30:14
--=-=-=


I've been configuring kernels for a new development board in the
evbarm tree, and in the process, have come across what appears to be
a bug in iostat code.

The as-configured system works fine, until I try to take it to
multiuser. At that point, it panics in kernel strncpy because
iostati_getnames has passed it a null pointer as the source argument.

The attached patch cures the symptom, but I think it's a band aid
rather than a solution.

I looked around the iostat related code a bit, and it looks as if a
system that has no possible disk drives will see this behavior, but
I'm not sure what the right final fix is.


--=-=-=
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=diffs
Content-Transfer-Encoding: base64
Content-Description: patch to subr_iostat.c

PT09PSAvc3JjL3N5cy9rZXJuL3N1YnJfaW9zdGF0LmMjMSAtIC9zcmMvc3lzL2tlcm4vc3Vicl9p
b3N0YXQuYyA9PT09CkBAIC0yNzQsMTIgKzI3NCwyMSBAQAogCQllbHNlIHsKIAkJCW1lbXNldChi
ZiwgMCwgc2l6ZW9mKGJmKSk7CiAJCQlpZiAoZmlyc3QpIHsKLQkJCQlzdHJuY3B5KGJmLCBzdGF0
cy0+aW9fbmFtZSwgc2l6ZW9mKGJmKSk7CisJCQkJaWYgKHN0YXRzLT5pb19uYW1lKSB7CisJCQkJ
CXN0cm5jcHkoYmYsIHN0YXRzLT5pb19uYW1lLCBzaXplb2YoYmYpKTsKKwkJCQl9IGVsc2Ugewor
CQkJCQlzdHJuY3B5KGJmLCAibm8gaW8gbmFtZSIsIHNpemVvZihiZikpOworCQkJCX0KIAkJCQlm
aXJzdCA9IDA7CiAJCQl9IGVsc2UgewogCQkJCWJmWzBdID0gJyAnOwotCQkJCXN0cm5jcHkoYmYg
KyAxLCBzdGF0cy0+aW9fbmFtZSwKLQkJCQkgICAgc2l6ZW9mKGJmKSAtIDEpOworCQkJCWlmIChz
dGF0cy0+aW9fbmFtZSkgeworCQkJCQlzdHJuY3B5KGJmICsgMSwgc3RhdHMtPmlvX25hbWUsCisJ
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