mount -p (displaying in fstab format) is buggy with unionfs mounts. How to reproduce: $ mkdir -p /tmp/jails/usr/local $ mount -t unionfs -o below -o noatime /usr/local /tmp/jails/testing/usr/local $ mount | grep unionfs <below>:/usr/local on /tmp/jails/usr/local (unionfs, NFS exported, local, noatime, nfsv4acls) $ $ mount -p | grep unionfs /u /tmp/jails/usr/local unionfs rw,noatime,nfsv4acls 0 0 => It is displaying "/u" in place of "/usr/local".
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a314c60625af1829b7e12c3a4cedb74d7f69d074 commit a314c60625af1829b7e12c3a4cedb74d7f69d074 Author: Jason A. Harmening <jah@FreeBSD.org> AuthorDate: 2024-12-22 06:36:30 +0000 Commit: Jason A. Harmening <jah@FreeBSD.org> CommitDate: 2024-12-30 00:39:49 +0000 mount(8): Avoid truncation when fstab-formatting unionfs mount info When displaying unionfs mounts in fstab format (`mount -p`), mount(8) currently uses strlcpy to remove the disposition prefix from the mount name returned by getmntinfo(3). But strlcpy, like strcpy before it, does not guarantee correct behavior if the source and destination buffers overlap. Just offset the buffer and avoid the destructive copy in the first place. PR: 283420 Reviewed by: imp (previous version), olce MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D48177 sbin/mount/mount.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=6584e5a1c54ff24ed7c9eb80a884b4e7f54e7288 commit 6584e5a1c54ff24ed7c9eb80a884b4e7f54e7288 Author: Jason A. Harmening <jah@FreeBSD.org> AuthorDate: 2024-12-22 06:36:30 +0000 Commit: Jason A. Harmening <jah@FreeBSD.org> CommitDate: 2025-01-09 06:10:00 +0000 mount(8): Avoid truncation when fstab-formatting unionfs mount info When displaying unionfs mounts in fstab format (`mount -p`), mount(8) currently uses strlcpy to remove the disposition prefix from the mount name returned by getmntinfo(3). But strlcpy, like strcpy before it, does not guarantee correct behavior if the source and destination buffers overlap. Just offset the buffer and avoid the destructive copy in the first place. PR: 283420 Reviewed by: imp (previous version), olce Differential Revision: https://reviews.freebsd.org/D48177 (cherry picked from commit a314c60625af1829b7e12c3a4cedb74d7f69d074) sbin/mount/mount.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)