Hi!

We have bumped into a problem with busybox mount, which does not handle
remounts very well if there are lines in /proc/mounts that are longer
than 504 bytes.

This happens in docker on fedora 43, which has the longest line of 591 bytes.

This can be reproduce with this patch:

diff --git a/util-linux/mount.c b/util-linux/mount.c
index d0f0ae1ad..9115207c5 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -2385,6 +2385,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
                // take -o opts from mtab (takes only mount source).
                fstabname = bb_path_mtab_file;
        }
+       // DEBUG
+       fstabname = "/tmp/fake-mounts";
        fstab = setmntent(fstabname, "r");
        if (!fstab)
                bb_perror_msg_and_die("can't read '%s'", fstabname);



and then create a /tmp/fake-mounts:

cat > /tmp/fake-mounts <<EOF
overlay / overlay 
rw,seclabel,relatime,lowerdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/15/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/6/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/5/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/4/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/1/fs,upperdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/16/fs,workdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/16/work
 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
EOF

Gives this error:

$ ./busybox_unstripped mount -o remount,rw /proc
mount: can't find /proc in /tmp/fake-mounts


I believe that GETMNTENT_BUFSIZE/2 is not enough, but I also don't see
any trivial way to solve this. I suppose we could simply malloc a
bigger buffer instead of doing tricks with bb_common_bufsiz1.

Any ideas?

-nc
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to