From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org, djwong@kernel.org, hch@lst.de
Cc: stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 3/7] xfs: check healthmon outbuffer space correctly
Date: Wed, 26 Aug 2026 22:33:14 -0700 [thread overview]
Message-ID: <178780640646.3528467.762348909259873415.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <178780640541.3528467.13867917797753503580.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
LOLLM notices that the outbuf space check in xfs_healthmon_format_pop
isn't quite correct -- it checks that there's enough space to write a
xfs_healthmon_event object, but the outbuffer is supposed to contain
xfs_health_monitor_event objects. Fix this by adding a helper, and
refactoring all three outbuf size checks to use it.
Cc: <stable@vger.kernel.org> # v7.0
Fixes: b3a289a2a9397b ("xfs: create event queuing, formatting, and discovery infrastructure")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/xfs_healthmon.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c
index ef2538a1ea6994..d0e0ecc6fc0c8f 100644
--- a/fs/xfs/xfs_healthmon.c
+++ b/fs/xfs/xfs_healthmon.c
@@ -758,6 +758,13 @@ static const unsigned int type_map[] = {
[XFS_HEALTHMON_DATALOST] = XFS_HEALTH_MONITOR_TYPE_DATALOST,
};
+static inline bool
+xfs_healthmon_check_outbuffer_space(const struct xfs_healthmon *hm)
+{
+ return hm->bufhead + sizeof(struct xfs_health_monitor_event) <=
+ hm->bufsize;
+}
+
/* Render event as a V0 structure */
STATIC int
xfs_healthmon_format_v0(
@@ -824,10 +831,10 @@ xfs_healthmon_format_v0(
break;
}
- ASSERT(hm->bufhead + sizeof(hme) <= hm->bufsize);
+ ASSERT(xfs_healthmon_check_outbuffer_space(hm));
/* copy formatted object to the outbuf */
- if (hm->bufhead + sizeof(hme) <= hm->bufsize) {
+ if (xfs_healthmon_check_outbuffer_space(hm)) {
memcpy(hm->buffer + hm->bufhead, &hme, sizeof(hme));
hm->bufhead += sizeof(hme);
}
@@ -910,7 +917,11 @@ xfs_healthmon_format_pop(
{
struct xfs_healthmon_event *event;
- if (hm->bufhead + sizeof(*event) > hm->bufsize)
+ /*
+ * Don't bother if there's not enough space to format even one event in
+ * the outbuffer.
+ */
+ if (!xfs_healthmon_check_outbuffer_space(hm))
return NULL;
mutex_lock(&hm->lock);
next prev parent reply other threads:[~2026-08-27 5:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 5:31 [PATCHSET v2 2/2] xfs: LLM-inspired bug fixes, part 8 Darrick J. Wong
2026-08-27 5:32 ` [PATCH 1/7] xfs: always set xfs_healthmon::first_event when inserting at front of list Darrick J. Wong
2026-08-31 6:54 ` Christoph Hellwig
2026-08-27 5:32 ` [PATCH 2/7] xfs: port healthmon event list to list_head Darrick J. Wong
2026-08-27 9:33 ` Anuj Gupta
2026-08-27 14:47 ` Darrick J. Wong
2026-08-31 6:58 ` Christoph Hellwig
2026-08-31 14:53 ` Darrick J. Wong
2026-08-31 6:58 ` Christoph Hellwig
2026-08-31 15:12 ` Darrick J. Wong
2026-08-27 5:33 ` Darrick J. Wong [this message]
2026-08-31 6:59 ` [PATCH 3/7] xfs: check healthmon outbuffer space correctly Christoph Hellwig
2026-08-27 5:33 ` [PATCH 4/7] xfs: merge healthmon insert/push helpers Darrick J. Wong
2026-08-31 6:59 ` Christoph Hellwig
2026-08-27 5:33 ` [PATCH 5/7] xfs: bump lost_prev_errors if we lose even the healthmon lost event Darrick J. Wong
2026-08-27 5:34 ` [PATCH 6/7] xfs: report nonexistent parents as a filesystem corruption Darrick J. Wong
2026-08-27 5:34 ` [PATCH 7/7] xfs: destroy seen inode bitmap when we fail to add a dirpath Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178780640646.3528467.762348909259873415.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox