Page MenuHomeFreeBSD

mksnap_ffs: fix running under chroot
ClosedPublic

Authored by sobomax on Sun, Sep 21, 9:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 7:26 PM
Unknown Object (File)
Fri, Oct 10, 5:44 PM
Unknown Object (File)
Fri, Oct 10, 5:44 PM
Unknown Object (File)
Fri, Oct 10, 5:44 PM
Unknown Object (File)
Fri, Oct 10, 12:41 PM
Unknown Object (File)
Fri, Oct 10, 5:58 AM
Unknown Object (File)
Mon, Oct 6, 4:03 AM
Unknown Object (File)
Thu, Oct 2, 9:15 PM
Subscribers

Details

Summary

There is a feature allowing mksnap_ffs to be executed in the chroot environment. It has been noticed that in some cases this feature does not work correctly, resulting in the FS mount point passed to the kernel to be truncated:

# ktrace mksnap_ffs /mnt/build-1133-20250920214034/.sfile
70844 mksnap_ffs CALL  nmount(0x34400ee30000,0xc,0x10201000<MNT_SOFTDEP|MNT_NOATIME|MNT_LOCAL>)
70844 mksnap_ffs NAMI  "/mnt/build-113"
70844 mksnap_ffs RET   nmount -1 errno 2 No such file or directory
70844 mksnap_ffs CALL  write(0x2,0x2921b8113420,0xc)
70844 mksnap_ffs GIO   fd 2 wrote 12 bytes
      "mksnap_ffs: "
70844 mksnap_ffs RET   write 12/0xc
70844 mksnap_ffs CALL  write(0x2,0x2921b8113510,0x3c)
70844 mksnap_ffs GIO   fd 2 wrote 60 bytes
      "Cannot create snapshot /mnt/build-1133-20250920214034/.sfile"
70844 mksnap_ffs RET   write 60/0x3c
70844 mksnap_ffs CALL  write(0x2,0x2921b953a8a9,0x2)
70844 mksnap_ffs GIO   fd 2 wrote 2 bytes
      ": "

The issue has been tracked down improper use of strlcpy() for overlapping strings, which in certain cases might cause truncation of the resulting string.

Test Plan

Run patched mksnap_ffs in the same environment when current version fails.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable