From: "Darrick J. Wong" <djwong@kernel.org>
To: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Cc: linux-xfs@vger.kernel.org, Carlos Maiolino <cem@kernel.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 RESEND 1/2] xfs: reject out-of-range attribute value lengths in xfs_attr_copy_value
Date: Wed, 23 Sep 2026 09:59:16 -0700 [thread overview]
Message-ID: <20260923165916.GF2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260923115823.3305596-2-qwe.aldo@gmail.com>
On Wed, Sep 23, 2026 at 08:58:22AM -0300, Aldo Ariel Panzardo wrote:
> xfs_attr_copy_value() takes the value length as a signed int and, for a
> remote xattr, is handed args->rmtvaluelen. That field is filled from the
> on-disk __be32 xfs_attr_leaf_name_remote.valuelen in
> xfs_attr3_leaf_getvalue(), so a crafted length such as 0x80000000 is
> stored into the signed rmtvaluelen as a negative number.
>
> The "buffer too small" guard in xfs_attr_copy_value() is a signed
> comparison:
>
> if (args->valuelen < valuelen)
> return -ERANGE;
>
> A negative valuelen therefore compares as smaller than the caller's
> buffer size, skips the -ERANGE path, and is then used as a copy length,
> leading to an out-of-bounds copy of a full remote block into a small
> getxattr(2) buffer on a mounted crafted image.
>
> Reject a value length that is negative or larger than the maximum xattr
> size before it is used, so a bogus on-disk length can no longer slip
> through the value copier.
>
> Fixes: 9df243a1a9e6 ("xfs: consolidate attribute value copying")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
I wonder if we /really/ need this check now that the leaf verifier is
getting fixed, but I do see the value in making sure that crazy sizes
don't get passed to kvmalloc later on, so:
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> v2: new patch (see the 0/2 cover letter). Fixes the signed value-length
> check in the consumer, xfs_attr_copy_value(), which is the root
> cause Darrick pointed at in his review of the v1 verifier patch.
>
> fs/xfs/libxfs/xfs_attr_leaf.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 86c5c09a5db4..d0f7753659c9 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -628,6 +628,17 @@ xfs_attr_copy_value(
> unsigned char *value,
> int valuelen)
> {
> + /*
> + * A value length that is negative or larger than the maximum xattr
> + * size is on-disk corruption. The remote value length is an on-disk
> + * __be32 stored into the signed args->rmtvaluelen, so a crafted value
> + * such as 0x80000000 becomes negative and would slip past the
> + * "args->valuelen < valuelen" check below and be used as a copy
> + * length. Reject it before that can happen.
> + */
> + if (valuelen < 0 || valuelen > XFS_XATTR_SIZE_MAX)
> + return -EFSCORRUPTED;
> +
> /*
> * Parent pointer lookups require the caller to specify the name and
> * value, so don't copy anything.
> --
> 2.53.0
>
>
next prev parent reply other threads:[~2026-09-23 16:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 11:58 [PATCH v2 RESEND 0/2] xfs: fix out-of-range remote xattr value length Aldo Ariel Panzardo
2026-09-23 11:58 ` [PATCH v2 RESEND 1/2] xfs: reject out-of-range attribute value lengths in xfs_attr_copy_value Aldo Ariel Panzardo
2026-09-23 16:59 ` Darrick J. Wong [this message]
2026-09-23 11:58 ` [PATCH v2 RESEND 2/2] xfs: reject remote xattr entries with an out-of-range value length Aldo Ariel Panzardo
2026-09-23 16:57 ` 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=20260923165916.GF2705364@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=qwe.aldo@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
all inboxes | Powered by JetHome®