NetBSD Problem Report #56742
From www@netbsd.org Sun Mar 6 07:46:56 2022
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))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 83E2D1A921F
for <gnats-bugs@gnats.NetBSD.org>; Sun, 6 Mar 2022 07:46:56 +0000 (UTC)
Message-Id: <20220306074655.2E6E71A9239@mollari.NetBSD.org>
Date: Sun, 6 Mar 2022 07:46:55 +0000 (UTC)
From: code-netbsd@boerschig.net
Reply-To: code-netbsd@boerschig.net
To: gnats-bugs@NetBSD.org
Subject: build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host
X-Send-Pr-Version: www-1.0
>Number: 56742
>Category: bin
>Synopsis: build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lukem
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 06 07:50:00 +0000 2022
>Closed-Date: Thu May 18 14:34:39 +0000 2023
>Last-Modified: Sat May 20 08:37:19 +0000 2023
>Originator: M Boerschig
>Release: 9.99.94
>Organization:
>Environment:
Linux localhost 5.13.0-30-generic #33~20.04.1-Ubuntu
>Description:
linuxbox$ ./build.sh -u -U -T ../tools -O ../obj -R ../release -D ../dest -N1 -m amd64 -j2 tools release install-image
...
nbmakefs errors out with:
Preparing spec files for makefs...
Creating rootfs...
nbmakefs: ffs_wtfs: seek error @-2071986688 for sector 4341759: Invalid argument
Calculated size of `work.rootfs': 2222981120 bytes, 10803 inodes
>How-To-Repeat:
On Ubuntu 20.04.4 host, run `build.sh tools release install-image`
>Fix:
daddr_t is defined as an int32_t, thus there is a 32bit integer overflow when calculating the sector offsets in usr.sbin/makefs/ffs/mkfs.c.
We should pass -D __daddr_t as int64_t, or alternatively the following fixes the issue for me (diff from git HEAD):
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
index 61cf74b4d4b9..1e9b794658c3 100644
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -796,7 +796,7 @@ ffs_rdfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
int n;
off_t offset;
- offset = bno * fsopts->sectorsize + fsopts->offset;
+ offset = (off_t)bno * fsopts->sectorsize + fsopts->offset;
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
err(EXIT_FAILURE, "%s: seek error for sector %lld", __func__,
(long long)bno);
@@ -819,7 +819,7 @@ ffs_wtfs(daddr_t bno, int size, void *bf, const fsinfo_t *fsopts)
int n;
off_t offset;
- offset = bno * fsopts->sectorsize + fsopts->offset;
+ offset = (off_t)bno * fsopts->sectorsize + fsopts->offset;
if (lseek(fsopts->fd, offset, SEEK_SET) == -1)
err(EXIT_FAILURE, "%s: seek error @%jd for sector %jd",
__func__, (intmax_t)offset, (intmax_t)bno);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: hgutch@NetBSD.org
State-Changed-When: Sun, 06 Mar 2022 08:49:06 +0000
State-Changed-Why:
I just committed a slightly different fix, see also
https://mail-index.netbsd.org/source-changes/2022/03/06/msg137358.html
Can you check if it fixes it for you too? And sorry, I had this lying
around locally for a few weeks but forgot to commit it.
From: "Harold Gutch" <hgutch@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56742 CVS commit: src/usr.sbin/makefs/ffs
Date: Sun, 6 Mar 2022 08:31:55 +0000
Module Name: src
Committed By: hgutch
Date: Sun Mar 6 08:31:54 UTC 2022
Modified Files:
src/usr.sbin/makefs/ffs: buf.h newfs_extern.h
Added Files:
src/usr.sbin/makefs/ffs: namespace.h
Log Message:
Make sure daddr_t is a 64 bit type when building tools.
(see also PR sw-bug/56742 ).
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/ffs/buf.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/ffs/namespace.h
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/ffs/newfs_extern.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/56742 (build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host)
Date: Sun, 6 Mar 2022 08:54:46 -0000 (UTC)
hgutch@NetBSD.org writes:
>Synopsis: build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host
>State-Changed-From-To: open->feedback
>State-Changed-By: hgutch@NetBSD.org
>State-Changed-When: Sun, 06 Mar 2022 08:49:06 +0000
>State-Changed-Why:
>I just committed a slightly different fix, see also
>https://mail-index.netbsd.org/source-changes/2022/03/06/msg137358.html
>Can you check if it fixes it for you too? And sorry, I had this lying
>around locally for a few weeks but forgot to commit it.
Does this help the embedded kernel code that also uses daddr_t (but without the namespace magic) ?
From: M Boerschig <code-netbsd@boerschig.net>
To: gnats-bugs@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
hgutch@NetBSD.org
Cc:
Subject: Re: bin/56742 (build.sh install-image fails with error in nbmakefs on
Ubuntu 20.04 host)
Date: Sun, 6 Mar 2022 20:13:37 +0100
Am 06.03.22 um 09:49 schrieb hgutch@NetBSD.org:
> Synopsis: build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host
>
> State-Changed-From-To: open->feedback
> State-Changed-By: hgutch@NetBSD.org
> State-Changed-When: Sun, 06 Mar 2022 08:49:06 +0000
> State-Changed-Why:
> I just committed a slightly different fix, see also
> https://mail-index.netbsd.org/source-changes/2022/03/06/msg137358.html
>
> Can you check if it fixes it for you too? And sorry, I had this lying
> around locally for a few weeks but forgot to commit it.
>
>
>
Yes, your fix allows me to cross-build from Ubuntu, too. Thanks!
State-Changed-From-To: feedback->closed
State-Changed-By: lukem@NetBSD.org
State-Changed-When: Thu, 18 May 2023 14:34:39 +0000
State-Changed-Why:
Fix confirmed by submitter (on 2022-03-06)
Responsible-Changed-From-To: bin-bug-people->lukem
Responsible-Changed-By: lukem@NetBSD.org
Responsible-Changed-When: Sat, 20 May 2023 08:37:19 +0000
Responsible-Changed-Why:
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.