NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/56742: build.sh install-image fails with error in nbmakefs on Ubuntu 20.04 host



>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:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 06 07:50:00 +0000 2022
>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);  



Home | Main Index | Thread Index | Old Index