NetBSD Problem Report #10278
Received: (qmail 25547 invoked from network); 4 Jun 2000 15:53:22 -0000
Message-Id: <200006041553.AAA01250@miyuki.my.domain>
Date: Mon, 5 Jun 2000 00:53:10 +0900 (JST)
From: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
Reply-To: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
To: gnats-bugs@gnats.netbsd.org
Subject: kernfs may hang kernel
X-Send-Pr-Version: 3.95
>Number: 10278
>Category: kern
>Synopsis: kernfs may hang kernel
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: jdolecek
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 04 15:54:00 +0000 2000
>Closed-Date: Fri Jul 19 18:38:07 +0000 2002
>Last-Modified: Fri Jul 19 18:38:07 +0000 2002
>Originator: IWAMOTO Toshihiro
>Release: 2 days old -current
>Organization:
>Environment:
System: NetBSD 1.4Z i386
>Description:
kernfs_getattr goes to an infinite loop if attributes of
/kern/msgbuf is requested and the kernel msgbuf is broken.
An infinite loop also happens if the hostname is 256-bytes
long and attributes of /kern/hostname is requested.
This happens because kernfs_getattr calls kernfs_xread in
a loop until it returns 0 (around line 498 of kernfs_vnops.c),
and kernfs_xread repeatedly returns non-zero values as error
codes in the above situations.
>How-To-Repeat:
build a kernel with a broken msgbuf or set its hostname
to 256-bytes long, and do "ls -l /kern"
>Fix:
The following code should work around the problem.
I don't know if better error handling is necessary.
--- kernfs_vnops.c.orig Thu Aug 26 07:54:17 1999
+++ kernfs_vnops.c Mon Jun 5 00:40:50 2000
@@ -234,7 +234,7 @@
*/
if (!msgbufenabled || msgbufp->msg_magic != MSG_MAGIC) {
msgbufenabled = 0;
- return (ENXIO);
+ return (0);
}
/*
@@ -261,7 +261,7 @@
int xlen = hostnamelen;
if (xlen >= (len-2))
- return (EINVAL);
+ return (0);
memcpy(*bufp, cp, xlen);
(*bufp)[xlen] = '\n';
>Release-Note:
>Audit-Trail:
From: Martin Husemann <martin@rumolt.teuto.de>
To: iwamoto@sat.t.u-tokyo.ac.jp (IWAMOTO Toshihiro)
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/10278: kernfs may hang kernel
Date: Sun, 4 Jun 2000 18:30:24 +0200 (MEST)
Wouldn't it be preferable to fix the loops in kernfs_getattr to check
for the error return codes?
Martin
Responsible-Changed-From-To: kern-bug-people->jdolecek
Responsible-Changed-By: jdolecek
Responsible-Changed-When: Tue Jul 9 16:00:58 PDT 2002
Responsible-Changed-Why:
I'll look at this.
State-Changed-From-To: open->closed
State-Changed-By: jdolecek
State-Changed-When: Fri Jul 19 11:36:15 PDT 2002
State-Changed-Why:
The bug was fixed, by changing kernfs_xread() to return errno or 0, and
passing len via separate argument.
This has been fixed in rev. 1.82 of syssrc/sys/miscfs/kernfs/kernfs_vnops.c
Thanks for report.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.