NetBSD Problem Report #56951

From he@smistad.uninett.no  Wed Aug  3 10:06:40 2022
Return-Path: <he@smistad.uninett.no>
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))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 97B531A921F
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  3 Aug 2022 10:06:40 +0000 (UTC)
Message-Id: <20220803100632.92CF7440139@smistad.uninett.no>
Date: Wed,  3 Aug 2022 12:06:32 +0200 (CEST)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: mtree for ./etc/localtime missing link= attribute
X-Send-Pr-Version: 3.95

>Number:         56951
>Category:       bin
>Synopsis:       mtree for ./etc/localtime missing link= attribute
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 03 10:10:00 +0000 2022
>Last-Modified:  Wed Aug 03 10:55:01 +0000 2022
>Originator:     Havard Eidnes
>Release:        NetBSD 9.99.99
>Organization:
   I try...
>Environment:
System: NetBSD stest.urc.uninett.no 9.99.97 NetBSD 9.99.97 (GENERIC) #7: Sun Jun  5 08:29:56 UTC 2022  he@stest.urc.uninett.no:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	This is building recently updated -current on 9.99.97 host.

	build.sh install-image fails with

Preparing spec files for makefs...
assertion "curnode->slink != NULL" failed: file "/usr/src/tools/makefs/../../usr
.sbin/makefs/walk.c", line 485, function "apply_specdir"
assertion "curnode->slink != NULL" failed: file "/usr/src/tools/makefs/../../usr
.sbin/makefs/walk.c", line 485, function "apply_specdir"
[1]   Abort trap (core dumped) /usr/tools/bin/nbmakefs -N /usr/src/etc -t cd9...
--- image ---

	Debugging the resulting nbmakefs.core with a nbmakefs built
	with MKDEBUGTOOLS=yes reveals:

Core was generated by `nbmakefs'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007d945579c87a in _lwp_kill () from /usr/lib/libc.so.12
(gdb) where
#0  0x00007d945579c87a in _lwp_kill () from /usr/lib/libc.so.12
#1  0x00007d945579cd7a in abort () from /usr/lib/libc.so.12
#2  0x00007d945579c16e in __assert13 () from /usr/lib/libc.so.12
#3  0x00000000004164a4 in apply_specdir (dir=0x7f7fffbb3650 "cdrom/etc", 
    specnode=0x7d9456467620, dirnode=0x7d945692c1e0, speconly=0)
    at /usr/src/tools/makefs/../../usr.sbin/makefs/walk.c:485
#4  0x0000000000416558 in apply_specdir (dir=0x7f7fffbb455a "cdrom", 
    specnode=0x7d9456467000, dirnode=0x7d945692c000, speconly=0)
    at /usr/src/tools/makefs/../../usr.sbin/makefs/walk.c:495
#5  0x0000000000415e2e in apply_specfile (specfile=0x7f7fffbb449d "fs.spec", 
    dir=0x7f7fffbb455a "cdrom", parent=0x7d945692c000, speconly=0)
    at /usr/src/tools/makefs/../../usr.sbin/makefs/walk.c:361
#6  0x0000000000411374 in main (argc=2, argv=0x7f7fffbb3d80)
    at /usr/src/tools/makefs/../../usr.sbin/makefs/makefs.c:312
(gdb) up
#1  0x00007d945579cd7a in abort () from /usr/lib/libc.so.12
(gdb) up
#2  0x00007d945579c16e in __assert13 () from /usr/lib/libc.so.12
(gdb) up
#3  0x00000000004164a4 in apply_specdir (dir=0x7f7fffbb3650 "cdrom/etc", 
    specnode=0x7d9456467620, dirnode=0x7d945692c1e0, speconly=0)
    at /usr/src/tools/makefs/../../usr.sbin/makefs/walk.c:485
485                                     assert(curnode->slink != NULL);
(gdb) p curfsnode->name
$1 = 0x7d94564794e0 "localtime"
(gdb) p curnode->slink
$2 = 0x0
(gdb) p/o curfsnode->type
$4 = 0120000
(gdb) 

	which matches S_IFLNK.

>How-To-Repeat:
	Try to do ./build.sh install-image (after "release") with
	freshly built tools.

>Fix:
	This change fixes it for me.
	Though it befuddles me why apparently nobody else is seeing
	this issue, so comments appreciated.

	This is the only type=link entry in etc/mtree/*.

% cvs diff special
Index: special
===================================================================
RCS file: /cvsroot/src/etc/mtree/special,v
retrieving revision 1.175
diff -u -r1.175 special
--- special     6 Jun 2022 10:56:28 -0000       1.175
+++ special     3 Aug 2022 09:51:51 -0000
@@ -101,7 +101,7 @@
 ./etc/iscsi/auths              type=file mode=0600 tags=nodiff
 ./etc/iscsi/targets            type=file mode=0644
 ./etc/ld.so.conf               type=file mode=0644 optional
-./etc/localtime                        type=link mode=0755
+./etc/localtime                        type=link mode=0755 link=/usr/share/zoneinfo/UTC
 ./etc/locate.conf              type=file mode=0644 optional
 ./etc/login.conf               type=file mode=0644 optional
 ./etc/mail                     type=dir  mode=0755

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/56951: mtree for ./etc/localtime missing link= attribute
Date: Wed, 3 Aug 2022 13:52:39 +0300

 On Wed, Aug 03, 2022 at 10:10:00 +0000, he@NetBSD.org wrote:

 > Synopsis: mtree for ./etc/localtime missing link= attribute

 This cannot be right, /etc/mtree/special is primarily for mtree
 security checks.  We cannot prescribe the user where their localtime
 symlink points to, can we?

 I haven't looked into the details, but two quick drive-by comments...
 Makefs should not crash on input it cannot make sense of.  There must
 be some spec file that tells makefs where localtime symlink points to
 in the image and that file can't be /etc/mtree/special, so you should
 probably try to figure out what that spec file is and why in your case
 it did end up using /etc/mtree/special (#2) and we should fix the
 crash (#1).

 -uwe

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.