NetBSD Problem Report #60986
From www@netbsd.org Tue Nov 10 18:44:32 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1AA9F1A923B
for <gnats-bugs@gnats.NetBSD.org>; Tue, 10 Nov 2026 18:44:32 +0000 (UTC)
Message-Id: <20261110184430.B2C1F1A923C@mollari.NetBSD.org>
Date: Tue, 10 Nov 2026 18:44:30 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: fssconfig panics on bad backing store type
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>
>Number: 60986
>Category: kern
>Synopsis: fssconfig panics on bad backing store type
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 10 18:45:00 +0000 2026
>Last-Modified: Mon Nov 16 20:35:01 +0000 2026
>Originator: Taylor R Campbell
>Release: current, 11, 10, ...
>Organization:
The S_IFMT Fssup
>Environment:
>Description:
fss(4) releases a vnode obtained with vn_open with vrele
instead of vn_close on error (if the vnode is neither VREG nor
VCHR, e.g. if it is VBLK instead).
791 error = vn_open(NULL, pb2, 0, FREAD|FWRITE, 0, &vp2, NULL, NULL);
...
800 if (vp2->v_type != VREG && vp2->v_type != VCHR) {
801 vrele(vp2);
802 pathbuf_destroy(pb2);
803 return EINVAL;
804 }
https://nxr.netbsd.org/xref/src/sys/dev/fss.c?r=1.116#791
This mistake leads to:
# fssconfig fss0 / /dev/ld4
[ 20.8227167] vnode 0xffff00007d3c3c00 flags 0x10<MPSAFE>
[ 20.8322628] tag VT_UFS(1) type VBLK(3) mount 0xffff00007dafc000 typedata 0xffff00007dd97f40
[ 20.8322628] usecount 1 writecount 1 holdcount 0
[ 20.8423793] size 100000000 writesize 100000000 numoutput 0
[ 20.8423793] data 0xffff00007d1f8940 lock 0xffff00007d3c3e80
[ 20.8423793] state LOADED key(0xffff00007dafc000 8) 94 06 00 00 00 00 00 00
[ 20.8525647] lrulisthd 0xffffc00001266790
[ 20.8525647] tag VT_UFS, ino 1684, on dev 168, 1 flags 0x0, nlink 1
[ 20.8525647] mode 060640, owner 0, group 5, size 0
[ 20.8625651] panic: vrelel: bad ref count
[ 20.8625651] cpu1: Begin traceback...
[ 20.8625651] trace fp ffffc000c6507900
[ 20.8726955] fp ffffc000c6507930 vpanic() at ffffc00000637940 netbsd:vpanic+0x1c0
[ 20.8941230] fp ffffc000c6507990 vnpanic() at ffffc000006ace18 netbsd:vnpanic+0x78
[ 20.9041283] fp ffffc000c6507a30 vrelel() at ffffc000006aef3c netbsd:vrelel+0xa9c
[ 20.9248854] fp ffffc000c6507ab0 fss_ioctl() at ffffc000006d858c netbsd:fss_ioctl+0xa48
[ 20.9571800] fp ffffc000c6507b70 cdev_ioctl() at ffffc0000061ed80 netbsd:cdev_ioctl+0x90
[ 20.9663878] fp ffffc000c6507bc0 spec_ioctl() at ffffc000006cc844 netbsd:spec_ioctl+0x58
[ 20.9765427] fp ffffc000c6507c00 VOP_IOCTL() at ffffc000006bd388 netbsd:VOP_IOCTL+0x40
[ 20.9981228] fp ffffc000c6507c50 vn_ioctl() at ffffc000006b371c netbsd:vn_ioctl+0xd0
[ 21.0091130] fp ffffc000c6507d50 sys_ioctl() at ffffc0000064eb3c netbsd:sys_ioctl+0x1bc
[ 21.0301681] fp ffffc000c6507e30 syscall() at ffffc000000c01bc netbsd:syscall+0x11c
>How-To-Repeat:
fssconfig fss0 / /dev/ld4
instead of
fssconfig fss0 / /dev/rld4
>Fix:
s/vrele/vn_close/, and some more testing
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:19:52 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:19:52 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Close vn_open with vn_close, not with vrele.
Fixes
# fssconfig fss0 / /dev/ld4
...
panic: vrelel: bad ref count
(The mistake is using the block device /dev/ld4 instead of the
character device /dev/rld4, but this ought to be handled gracefully,
not by panicking.)
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:19:59 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:19:59 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Sprinkle assertions in state transitions.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:20:06 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:20:06 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Initialize sc_state in fss_attach, not fss_open.
Access without sc_slock is forbidden.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:20:16 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:20:16 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Free cfdata_t in error branch.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:20:25 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:20:25 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Handle fss_softc_alloc failure.
Shouldn't successfully transition to FSS_ACTIVE in that case; should
instead back out and fail.
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:20:36 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:20:35 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Rework creation path to avoid various races.
1. Look up each vnode exactly once; the identity of the vnode may
change between lookups otherwise.
2. Don't read v_vflag or v_mount without holding the vnode lock;
otherwise they may be changed by concurrent revoke.
3. Hold vfs_busy(mp) while we don't have one of its vnode's locked
and we haven't committed the fss instance to FSS_ACTIVE (at which
point fss_unmount_hook will take care of it).
4. Set sc->sc_uflags at the same time the transition to FSS_ACTIVE,
and loosen assertion after fss_create_snapshot, to avoid a race
between FSSIOCSET and FSSIOCCLR. See comments in FSSIOCSET for
details.
XXX Should consider using namei and VOP_REMOVE instead of
do_sys_unlink to remove only the vnode that we actually looked up,
not whatever might be there later.
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:20:47 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:20:47 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Avoid races with drvctl detach.
Attach and detach by opening and closing /dev/fssN is serialized by
fss_device_lock, but concurrent `drvctl -d fssN' can cause an fss
instance to be detached and freed while fss_open or fss_close is
still trying to use it.
Prevent concurrent detach during other operations like fss_ioctl or
fss_strategy by making fss_detach fail if sc_flags shows it is held
open.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:01 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:01 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Serialize fss_num_attached / fss_vfs_hooks access.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:09 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:09 UTC 2026
Modified Files:
src/sys/dev: fss.c fssvar.h
Log Message:
fss(4): Omit needless kmem_alloc for struct disk sc_dkdev.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/fss.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/fssvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:18 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:18 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Gather module init/fini logic into one place.
Fixes some little-used error branches and avoids duplication that can
get out of sync.
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:25 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:25 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Ensure newly attached autoconf unit matches dev_t minor.
Setting cf->cf_fstate = FSTATE_STAR means autoconf(9) may select any
unit from cf->cf_unit onward, rather than only cf->cf_unit. Since
the attach is always serialized by fss_device_lock, this proably
doesn't make a difference in practice -- and we can't get rid of
fss_device_lock without a config_intern_pseudo_acquire or something
that atomically acquires the existing unit or if there is none
attaches a new one. But let's make the intent clearer in case any of
that changes.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:32 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:32 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Install a cancel handler.
This way, fss_close doesn't run until all concurrent I/O operations
(read, write, ioctl, strategy) have returned. Note that this applies
independently to the bdev and the cdev, so (e.g.) fss_close may run
on the cdev while there's still an fss_strategy running in parallel.
But in that case, sc->sc_flags will have FSS_BDEV_OPEN set, so
fss_close won't try to detach it too soon.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:40 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:39 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Tighten fss_close -> fss_detach path.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:21:50 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:21:50 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Tighten fss_close a bit.
Clear last FSS_CDEV_OPEN/FSS_BDEV_OPEN in fss_close so we can assert
it in fss_detach, and pass DETACH_FORCE to fss_detach so it knows
when to expect the flags to be cleared.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:28:31 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:28:31 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Nix needless sc == NULL conditionals.
fss_strategy and fss_ioctl can be reached only after fss_open has
returned and (now that fss_cancel exists) before fss_close has been
called (on both block _and_ all character devices that have been
opened); between (first) open and (last) close, the autoconf unit
must exist.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:29:05 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:29:05 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Use LK_SHARED, not LK_EXCLUSIVE, to read out mount point.
No need to exclude other readers.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys/dev
Date: Mon, 16 Nov 2026 20:29:44 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:29:44 UTC 2026
Modified Files:
src/sys/dev: fss.c
Log Message:
fss(4): Revoke vnodes when unconfiguring.
This way, if you unconfigure an fss instance and reconfigure it,
anything that had it open (e.g., a file system mounted from it) won't
suddenly start mixing old cached data with new data -- instead, new
I/O operations will fail.
Not perfect -- see comments.
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/fss.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60986 CVS commit: src/sys
Date: Mon, 16 Nov 2026 20:30:07 +0000
Module Name: src
Committed By: riastradh
Date: Mon Nov 16 20:30:07 UTC 2026
Modified Files:
src/sys/kern: kern_drvctl.c subr_autoconf.c
src/sys/sys: device.h
Log Message:
autoconf(9): Take device references in iteration for detach.
This avoids a race with concurrent detach that can lead to tripping
KASSERT(!dv->dv_detach_done) in config_detach -> device_acquire, even
if the device_t itself remains stable while the device iteration is
ongoing (because alldev_nwrite or alldev_nread is raised).
While here, add:
- deviter_first_acquire
- deviter_next_acquire
- device_find_by_xname_acquire
- device_find_by_driver_unit_acquire
Prompted by:
PR kern/60986: fssconfig panics on bad backing store type
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/kern_drvctl.c
cvs rdiff -u -r1.321 -r1.322 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.194 -r1.195 src/sys/sys/device.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(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.