mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: Michael Bommarito <michael.bommarito@gmail.com>
Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Andreas Gruenbacher <agruenba@redhat.com>
Subject: Re: [PATCH] gfs2: reject an over-long name in get_name_filldir
Date: Mon, 13 Jul 2026 19:40:08 +0100	[thread overview]
Message-ID: <a9bdedcd-cb49-4b6a-bf78-ba6f03b3d511@redhat.com> (raw)
In-Reply-To: <20260711150808.2919076-1-michael.bommarito@gmail.com>

On 11/07/2026 16:08, Michael Bommarito wrote:
> get_name_filldir() copies a directory entry name into the caller's fixed
> GFS2_FNAMESIZE-byte buffer with memcpy(gnfd->name, name, length) without

I don't see a GFS2_FNAMESIZE-byte buffer but it looks like gnfd->name is pointing to the `char nbuf[NAME_MAX+1]` in exportfs_decode_fh_raw(), but that's just a 1-byte difference so it doesn't change the conversation much.

> checking length against GFS2_FNAMESIZE. A gfs2 directory entry whose name
> length exceeds GFS2_FNAMESIZE, as produced by a corrupted or crafted
> on-disk directory, overflows the buffer.

I think the on-disk dirents should have been checked closer to the dirent read path before we get to the get_name() path.

> Impact: an out-of-bounds write past the GFS2_FNAMESIZE name buffer (KASAN)

Do you have a KASAN backtrace?

> in the NFS-export get_name path, reachable when a gfs2 filesystem carrying
> a crafted directory entry is re-exported over NFS.
> 
> Reject entries whose name length exceeds GFS2_FNAMESIZE before the copy.
> 

gfs2_check_dirent() is likely a better place to add the validation.

Andy

> Fixes: b3b94faa5fe5 ("[GFS2] The core of GFS2")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> ---
>  fs/gfs2/export.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
> index 3334c394ce9cb..7b28f1eb9ad0d 100644
> --- a/fs/gfs2/export.c
> +++ b/fs/gfs2/export.c
> @@ -76,6 +76,9 @@ static bool get_name_filldir(struct dir_context *ctx, const char *name,
>  	if (inum != gnfd->inum.no_addr)
>  		return true;
>  
> +	if (length > GFS2_FNAMESIZE)
> +		return false;
> +
>  	memcpy(gnfd->name, name, length);
>  	gnfd->name[length] = 0;
>  


      reply	other threads:[~2026-07-13 18:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11 15:08 Michael Bommarito
2026-07-13 18:40 ` Andrew Price [this message]

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=a9bdedcd-cb49-4b6a-bf78-ba6f03b3d511@redhat.com \
    --to=anprice@redhat.com \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.bommarito@gmail.com \
    --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

Powered by JetHome