Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, hch@lst.de, stable@vger.kernel.org,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/5] xfs: check healthmon outbuffer space correctly
Date: Tue, 25 Aug 2026 08:44:51 +0200	[thread overview]
Message-ID: <20260825064451.GB24532@lst.de> (raw)
In-Reply-To: <178760941123.944364.14413050986149192404.stgit@frogsfrogsfrogs>

On Mon, Aug 24, 2026 at 10:36:28PM -0700, Darrick J. Wong wrote:
> 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 |   16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> 
> diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c
> index 166ef0d5864486..a2ae15a262a510 100644
> --- a/fs/xfs/xfs_healthmon.c
> +++ b/fs/xfs/xfs_healthmon.c
> @@ -739,6 +739,12 @@ 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;

Overly long line.

>  		memcpy(hm->buffer + hm->bufhead, &hme, sizeof(hme));
>  		hm->bufhead += sizeof(hme);
>  	}
> @@ -891,7 +897,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);

This is a bit annoying as we now require the type name instead of an
object, and the v0 implies there could be other formats.  But I guess
for now it is fine..

  reply	other threads:[~2026-08-25  6:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  5:34 [PATCHSET 2/2] xfs: LLM-inspired bug fixes, part 8 Darrick J. Wong
2026-08-25  5:36 ` [PATCH 1/5] xfs: always set xfs_healthmon::first_event when inserting at front of list Darrick J. Wong
2026-08-25  6:40   ` Christoph Hellwig
2026-08-25 18:33     ` Darrick J. Wong
2026-08-26  4:48       ` Christoph Hellwig
2026-08-26  4:54         ` Darrick J. Wong
2026-08-26  5:10           ` Christoph Hellwig
2026-08-25  5:36 ` [PATCH 2/5] xfs: check healthmon outbuffer space correctly Darrick J. Wong
2026-08-25  6:44   ` Christoph Hellwig [this message]
2026-08-25 18:36     ` Darrick J. Wong
2026-08-25  5:36 ` [PATCH 3/5] xfs: bump lost_prev_errors if we lose even the healthmon lost event Darrick J. Wong
2026-08-25  6:45   ` Christoph Hellwig
2026-08-25  5:36 ` [PATCH 4/5] xfs: report nonexistent parents as a filesystem corruption Darrick J. Wong
2026-08-25  6:46   ` Christoph Hellwig
2026-08-25  5:37 ` [PATCH 5/5] xfs: destroy seen inode bitmap when we fail to add a dirpath Darrick J. Wong
2026-08-25  6:48   ` Christoph Hellwig

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=20260825064451.GB24532@lst.de \
    --to=hch@lst.de \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --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