NetBSD Problem Report #60947

From tsutsui@ceres.dti.ne.jp  Sat Oct 31 15:59:59 2026
Return-Path: <tsutsui@ceres.dti.ne.jp>
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 4A7ED1A923C
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 31 Oct 2026 15:59:59 +0000 (UTC)
Message-Id: <202610311559.69VFxs37002463@ceres.dti.ne.jp>
Date: Sun, 1 Nov 2026 00:59:54 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: makefs(8) -t ffs -o version=2 creates superblock at SBLOCK_UFS1
X-Send-Pr-Version: 3.95
X-From4GNATS: "Izumi Tsutsui via gnats" <gnats-admin@NetBSD.org>

>Number:         60947
>Category:       bin
>Synopsis:       makefs(8) -t ffs -o version=2 creates superblock at SBLOCK_UFS1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 31 16:00:01 +0000 2026
>Originator:     Izumi Tsutsui
>Release:        NetBSD 11.0
>Organization:
>Environment:
System: NetBSD mirage 11.0 NetBSD 11.0 (GENERIC)
Architecture: all
Machine: all

>Description:
I think FFSv2 requires superblocks allocated at SBLOCK_UFS2 (65536),
but current makefs(8) creates superblock for UFS2 at SBLOCK_UFS1 (8192).

It looks intentional per XXX comment:

 https://nxr.netbsd.org/xref/src/usr.sbin/makefs/ffs/mkfs.c?r=1.43#305
```
    305 #if 0 /* XXX makefs is used for small filesystems. */
    306 		sblock.fs_sblockloc = SBLOCK_UFS2;
    307 #else
    308 		sblock.fs_sblockloc = SBLOCK_UFS1;
    309 #endif
```

However I'm afraid this could be problematic because:

- FFSv2 created by makefs(8) is different from ones by newfs(8)
- No options to create FFSv2 as newfs(8) (superblock at SBLOCK_UFS2)
- In future MD developers would assume FFSv2 always reserves 32KB for
  bootloaders?

It looks kernel, and libsa/ffs.c check SBLOCK_UFS2 and then
SBLOCK_UFS1 (via SBLOCKSEARCH etc.) even for FFSv2, though.

>How-To-Repeat:

```
% cd /tmp
% mkdir test
% makefs -t ffs -o version=2 -m 1m -M 1m test.fs test
 [...]
% hexdump -Cv test.fs
 :
00002550  00 00 00 00 00 00 00 00  00 00 00 00 38 20 01 19  |............8 ..|
 :
```

Note makefs(8) always UFS2ea for version=2 as filed in PR/60938:
 https://mail-index.netbsd.org/netbsd-bugs/2026/10/29/msg096098.html
so magic is FS_UFS2EA_MAGIC (0x19012038), not FS_UFS2_MAGIC (0x19540119).


I'm not sure if it's safe to create FFSv2 with bsize=65536
because the first superblock backup is allocated at SBLOCK_UFS2:

```
% makefs -t ffs -o version=2,bsize=65536,fsize=8192 -m 1m -M 1m test.fs test
Calculated size of `test.fs': 1048576 bytes, 2 inodes
Extent size set to 65536
test.fs: 1.0MB (2048 sectors) block size 65536, fragment size 8192
        using 1 cylinder groups of 1.00MB, 16 blks, 256 inodes.
super-block backups (for fsck -b #) at:
 128,
Populating `test.fs'
Image `test.fs' complete
% hexdump -Cv test.fs | grep ' 38 20 01 19 '
00002550  00 00 00 00 00 00 00 00  00 00 00 00 38 20 01 19  |............8 ..|
00010550  00 00 00 00 00 00 00 00  00 00 00 00 38 20 01 19  |............8 ..|
% 
```

It looks fsck_ffs(8) checks SBLOCK_UFS2 first, but doesn't check
fs_blockloc.

>Fix:
No idea. Check and clarify FFSv2 spec?
Add an option to select the superblock position for FFSv2?

---
Izumi Tsutsui

NetBSD Home
NetBSD PR Database Search

(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.