Re: Panic on attempt to kern_stat / mount bad fs

From: Garrett Cooper <yanefbsd_at_gmail.com>
Date: Sun, 27 Apr 2008 18:07:33 -0700
On Apr 27, 2008, at 5:52 PM, Garrett Cooper wrote:

> Trying to use more of my harddisk, I formatted 2 labels I previously  
> fdisked on my machine (note that there wasn't a modification in MBRs  
> or slices, just partitions).
>
> Later on, I was recompiling my kernel and world recently and my  
> machine took a nose dive (panicked) partway through. The machine  
> rebooted by itself (to my surprise) and subsequently panicked again  
> attempting to mount one of the newly formatted filesystems.
>
> I quickly logged in locally, removed the 1/2 filesystems from my  
> fstab automount list and rebooted yet again. After that, and once I  
> removed background_fsck_enable=YES from rc.conf, everything appears  
> to be smooth sailing (knock on wood).
>
> I have 2 vmcore's that I can debug with: one from the first panic  
> and another from the 2nd panic.
>
> (I had to rebuild the kernel after I removed apcupsd as I have a USB  
> kbd and apcupsd provides uhid -- well, sort of...).
>
> optimus# uname -a
> FreeBSD optimus 8.0-CURRENT FreeBSD 8.0-CURRENT #14: Sun Apr 27  
> 17:09:22 PDT 2008     root_at_optimus:/usr/obj/usr/src/sys/OPTIMUS  i386
>
> I'll provide more info when requested.
>
> Thanks,
> -Garrett

Looks like there might be some missing error checking logic in the fs  
area:

optimus# kgdb -c /var/crash/vmcore.0 /boot/kernel.old/kernel
kgdb: kvm_nlist(_stopped_cpus):
kgdb: kvm_nlist(_stoppcbs):
[GDB will not be able to debug user-mode threads: /usr/lib/ 
libthread_db.so: Undefined symbol "ps_pglobal_lookup"]
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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 "i386-marcel-freebsd".

Unread portion of the kernel message buffer:
panic: ufs_dirbad: /scratch: bad dir ino 2 at offset 0: mangled entry
Uptime: 9d16h44m22s
Physical memory: 2038 MB
Dumping 250 MB: 235 219 203 187 171 155 139 123 107 91 75 59 43 27 11

#0  doadump () at pcpu.h:195
195	pcpu.h: No such file or directory.
	in pcpu.h
(kgdb) up 10
#10 0xc062c17b in kern_stat (td=0xc53c5000, path=0xbfbfe2d4 <Address  
0xbfbfe2d4 out of bounds>, pathseg=UIO_USERSPACE, sbp=0xe7debc18) at / 
usr/src/sys/kern/vfs_syscalls.c:2109
2109		if ((error = namei(&nd)) != 0)
(kgdb) bt
#0  doadump () at pcpu.h:195
#1  0xc05b52c5 in boot (howto=260) at /usr/src/sys/kern/ 
kern_shutdown.c:409
#2  0xc05b54d4 in panic (fmt=Variable "fmt" is not available.
) at /usr/src/sys/kern/kern_shutdown.c:563
#3  0xc06e2b97 in ufs_dirbad (ip=0x0, offset=0, how=0xc0795460  
"mangled entry") at /usr/src/sys/ufs/ufs/ufs_lookup.c:598
#4  0xc06e3b5c in ufs_lookup (ap=0xe7deba04) at /usr/src/sys/ufs/ufs/ 
ufs_lookup.c:288
#5  0xc0750f02 in VOP_CACHEDLOOKUP_APV (vop=0xc07d0360, a=0xe7deba04)  
at vnode_if.c:153
#6  0xc0618390 in vfs_cache_lookup (ap=0xe7deba84) at vnode_if.h:83
#7  0xc07528d1 in VOP_LOOKUP_APV (vop=0xc07d0880, a=0xe7deba84) at  
vnode_if.c:99
#8  0xc061e4fc in lookup (ndp=0xe7debba8) at vnode_if.h:57
#9  0xc061f143 in namei (ndp=0xe7debba8) at /usr/src/sys/kern/ 
vfs_lookup.c:219
#10 0xc062c17b in kern_stat (td=0xc53c5000, path=0xbfbfe2d4 <Address  
0xbfbfe2d4 out of bounds>, pathseg=UIO_USERSPACE, sbp=0xe7debc18) at / 
usr/src/sys/kern/vfs_syscalls.c:2109
#11 0xc062c315 in stat (td=0xc53c5000, uap=0xe7debcfc) at /usr/src/sys/ 
kern/vfs_syscalls.c:2093
#12 0xc073c423 in syscall (frame=0xe7debd38) at /usr/src/sys/i386/i386/ 
trap.c:1008
#13 0xc0726b60 in Xint0x80_syscall () at /usr/src/sys/i386/i386/ 
exception.s:196
#14 0x00000033 in ?? ()
Previous frame inner to this frame (corrupt stack?)
(kgdb) up
#11 0xc062c315 in stat (td=0xc53c5000, uap=0xe7debcfc) at /usr/src/sys/ 
kern/vfs_syscalls.c:2093
2093		error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
(kgdb) p *uap
$1 = {path_l_ = 0xe7debcfc "?⿿?ؿ?Z", path = 0xbfbfe2d4 <Address  
0xbfbfe2d4 out of bounds>, path_r_ = 0xe7debd00 "?ؿ?Z", ub_l_ =  
0xe7debd00 "?ؿ?Z", ub = 0xbfbfd8d4, ub_r_ = 0xe7debd04 "Z"}
(kgdb)
Received on Sun Apr 27 2008 - 23:06:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:30 UTC