From: Darrick J. Wong Date: Thu, 11 Jun 2026 14:06:08 +0000 (-0700) Subject: xfs_healer_start: increase statmount buffer size X-Git-Tag: v7.1.0~41 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76ef8d90a3f021e61aafeea456e62f2cb1b61167;p=xfsprogs-dev.git xfs_healer_start: increase statmount buffer size 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" Reviewed-by: Andrey Albershteyn --- diff --git a/healer/xfs_healer_start.c b/healer/xfs_healer_start.c index 6bf2b9bf..b964aa13 100644 --- a/healer/xfs_healer_start.c +++ b/healer/xfs_healer_start.c @@ -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. */