]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_healer_start: increase statmount buffer size
authorDarrick J. Wong <djwong@kernel.org>
Thu, 11 Jun 2026 14:06:08 +0000 (07:06 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 17 Jun 2026 10:49:27 +0000 (12:49 +0200)
Codex points out that our statmount call asks for the mount point,
filesystem type, and mount root data for each mount.  The first and
last items in that sequence are paths, so we need at least PATH_MAX for
each of them to avoid overflowing the buffer.  I don't know what is the
maximum filesystem type string length so we'll just hope that NAME_MAX
is enough.  Switch the allocation to dynamic because 9k is a lot.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
healer/xfs_healer_start.c

index 6bf2b9bf854e6d9c9b4af7d6e7bcbb9845107e13..b964aa13ef1049840e185a36e33a682cd4ed53c9 100644 (file)
@@ -67,15 +67,22 @@ examine_mount(
        int                     mnt_ns_fd,
        uint64_t                mnt_id)
 {
-       size_t                  smbuf_size = libfrog_statmount_sizeof(4096);
-       struct statmount        *smbuf = alloca(smbuf_size);
+       /* two paths and a filesystem type string of unknown length */
+       size_t                  smbuf_size =
+               libfrog_statmount_sizeof(PATH_MAX * 2 + NAME_MAX);
+       struct statmount        *smbuf = malloc(smbuf_size);
        int                     ret;
 
+       if (!smbuf) {
+               perror("statmount alloc");
+               return;
+       }
+
        ret = libfrog_statmount(mnt_id, mnt_ns_fd, REQUIRED_STATMOUNT_FIELDS,
                        smbuf, smbuf_size);
        if (ret) {
                perror("statmount");
-               return;
+               goto out_smbuf;
        }
 
        if (debug) {
@@ -93,11 +100,13 @@ examine_mount(
        /* Look for mount points for the root dir of an XFS filesystem. */
        if ((smbuf->mask & REQUIRED_STATMOUNT_FIELDS) !=
                           REQUIRED_STATMOUNT_FIELDS)
-               return;
+               goto out_smbuf;
 
        if (!strcmp(smbuf->str + smbuf->fs_type, "xfs") &&
            !strcmp(smbuf->str + smbuf->mnt_root, "/"))
                start_healer(smbuf->str + smbuf->mnt_point);
+out_smbuf:
+       free(smbuf);
 }
 
 /* Translate fanotify mount events into something we can process. */