Re: [PATCH] xfs: reject remote xattr entries with an out-of-range value length
From: Darrick J. Wong
Date: Tue Jul 07 2026 - 12:38:06 EST
On Tue, Jul 07, 2026 at 11:01:18AM -0300, Aldo Ariel Panzardo wrote:
> xfs_attr3_leaf_verify_entry() validates a remote attribute entry's name
> but never bounds its on-disk value length (xfs_attr_leaf_name_remote.
> valuelen, a __be32). A crafted leaf with valuelen = 0x80000000 passes
> the verifier and the CRC.
>
> That length is later assigned into the signed int args->rmtvaluelen
> (xfs_attr3_leaf_getvalue), becoming negative, which slips past the signed
> -ERANGE check in xfs_attr_copy_value(); a getxattr() with a small buffer
Shouldn't you fix the signed value check in xfs_attr_copy_value, then?
> then memcpy()s a full remote block into the small kvalue buffer
> (xfs_attr_rmtval_copyout) -- a heap out-of-bounds write with
> attacker-controlled content, from an unprivileged getxattr(2) on a
> mounted crafted image.
>
> Reject remote entries whose value length exceeds XFS_XATTR_SIZE_MAX in
> the leaf verifier, so the malicious block is rejected at read time.
>
> Fixes: c84760659dcf ("xfs: check attribute leaf block structure")
> Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@xxxxxxxxx>
This ought to cc stable.
> ---
> fs/xfs/libxfs/xfs_attr_leaf.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 86c5c09a5db4..f1769289f908 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -339,6 +339,8 @@ xfs_attr3_leaf_verify_entry(
> if (!(ent->flags & XFS_ATTR_INCOMPLETE) &&
> rentry->valueblk == 0)
> return __this_address;
> + if (be32_to_cpu(rentry->valuelen) > XFS_XATTR_SIZE_MAX)
> + return __this_address;
This looks correct though.
--D
> }
>
> if (name_end > buf_end)
> --
> 2.43.0
>
>