From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F082E469851; Tue, 25 Aug 2026 13:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787666228; cv=none; b=agQp851S5pfM0Wll17HERah5uQvwU8hsUHi5Sf7quYWIwvyKMf/Kbq/My2PkQcIqTThzSKD87g1TkeO9pe2GSbmGjbJuaaDbMOvkEgtWnd0QhNIF8NaWbsRpC/DDdmbf7kcdoDLZ0FiSmrNzHaJrLgZVMr/yhjvhxHw1FkQ4TTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787666228; c=relaxed/simple; bh=bZhJ9WVLIgNzKiz8f23NzpaqSYZL0JJ267eX+InuMGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=suyav9672k7sL1mdWEW9+erZzVd1022Ns3P8ZirF3DNZlL2pHoGCxkFSbnaSrsAGGFHKlWdAPQy6Qy1VBygsAzKCRkldzz00Rq5jsJv7hQNsYH//XPanCKYjLmSyJ3H3R+yrs36iX7M0DwiY9mKflqO4tRpl3b1kwsYaYRXivzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DqZLcEg6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DqZLcEg6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24E571F000E9; Tue, 25 Aug 2026 13:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787666226; bh=doEaGNYY4uGdRMSnLt3yrRYcymMZK+Z7lzi4LiDAc0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DqZLcEg6gx6JO33XKDdhhA7SxCJbcc7tCH/ngyIJgNRruJ2VcmT3P5+Ke+VP/ic7e cU/W9uVh5vfgB2mCgsvOVCqxUn/zSPwaqGT6z32MqKdeINv6myO8RkcGiKkOzDTUaU QO6JydjlHqOq5WV0/6m9gYrPgnjXIkTlArfLVQx4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hongling Zeng , "Darrick J. Wong" , Carlos Maiolino Subject: [PATCH 5.15 09/76] xfs: validate attr entry pointer before field access Date: Tue, 25 Aug 2026 15:26:02 +0200 Message-ID: <20260825132541.902237430@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825132541.568214149@linuxfoundation.org> References: <20260825132541.568214149@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hongling Zeng commit b7eea80be25f3334f131d52982b3131aba77b97d upstream. xfs_attr3_leaf_verify_entry() accesses lentry/rentry fields (namelen, valuelen) before checking if the entry pointer itself is within bounds. If nameidx is crafted to point near the end of the buffer, these field accesses can read out-of-bounds before the bounds check at name_end > buf_end is performed. Add explicit bounds checks for entry pointers before accessing their fields. Use offsetof() to check that the start of the flexible array member (nameval/name) is within bounds, which ensures all preceding fields are safe to access. Fixes: c84760659dcf2 ("xfs: check attribute leaf block structure") Cc: # v5.5 Signed-off-by: Hongling Zeng Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_attr_leaf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -266,6 +266,13 @@ xfs_attr3_leaf_verify_entry( */ if (ent->flags & XFS_ATTR_LOCAL) { lentry = xfs_attr3_leaf_name_local(leaf, idx); + + /* Validate lentry pointer is within bounds before field access */ + if ((char *)lentry >= buf_end) + return __this_address; + if ((char *)lentry + offsetof(struct xfs_attr_leaf_name_local, nameval) > buf_end) + return __this_address; + namesize = xfs_attr_leaf_entsize_local(lentry->namelen, be16_to_cpu(lentry->valuelen)); name_end = (char *)lentry + namesize; @@ -273,6 +280,13 @@ xfs_attr3_leaf_verify_entry( return __this_address; } else { rentry = xfs_attr3_leaf_name_remote(leaf, idx); + + /* Validate rentry pointer is within bounds before field access */ + if ((char *)rentry >= buf_end) + return __this_address; + if ((char *)rentry + offsetof(struct xfs_attr_leaf_name_remote, name) > buf_end) + return __this_address; + namesize = xfs_attr_leaf_entsize_remote(rentry->namelen); name_end = (char *)rentry + namesize; if (rentry->namelen == 0)