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 5140E4307AD; Tue, 21 Jul 2026 20:11:49 +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=1784664710; cv=none; b=rbomF+X4N2BVk9KIdtw70iKjUEMWH+udm7gWp+3yREk76j/FhmihsFTTfL3sroPS0cIstu1OJjWSuibPo+lf3P1dPkQUUVT4GXRIJkiQFeP72rNczsS6DZ4wFZaYqrNnTWLc/MZ/WiDUc6PtnicJ1a3CyrftkWIAx65QPSQngKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784664710; c=relaxed/simple; bh=09DHvKcTzsb/LWS1KL3MvrSJ/0RNpnlmlxkiv/2xKDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJYCAsMAGSNgZTT6wFYex7LhvJTBDVUozhu4NRKplNUzqjPWRwxgGcwpn9lE6kXGy6g94+WTwDzQ98lxEoueWnPNvisPiUbxytKSpkGjJhc5Mxi81JkLM0VulbNprJpUDhAm/53QGeNjMh6weW/7WFuHjZKlHN7uaaeyV4ueg10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rIP1uftu; 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="rIP1uftu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7A721F000E9; Tue, 21 Jul 2026 20:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784664709; bh=veKoevR6iN0io4ueEUlCAS0AGXipqRuT7iX+4lyWx/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rIP1uftuGjs03R/2/H41yvO7yLf+pK1S/x/A3Qy/NfdYLJqDy/xK1YkFz7Zc0e9cd Alp5aOS5cdMjT+2u36HFvSsCmAtPwufUiLSi3BAGvRfcUfheTtbWHcmswdrmVsWmHX 8lDgSW4RI1EXA4nsv/l0Q9aVisOJ5UI0VzC2GM/4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Chao Yu , Keshav Verma , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.6 0029/1266] f2fs: fix listxattr handling of corrupted xattr entries Date: Tue, 21 Jul 2026 17:07:46 +0200 Message-ID: <20260721152442.447242842@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Keshav Verma [ Upstream commit 5ef5bc304f23c3fe255d4936472378dcb74d0e94 ] Validate the xattr entry before reading its fields in f2fs_listxattr(). Return -EFSCORRUPTED when the entry is outside the valid xattr storage area instead of returning a successful partial result. Fixes: 688078e7f36c ("f2fs: fix to avoid memory leakage in f2fs_listxattr") Cc: stable@kernel.org Reviewed-by: Chao Yu Signed-off-by: Keshav Verma Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/xattr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -581,8 +581,6 @@ ssize_t f2fs_listxattr(struct dentry *de size_t prefix_len; size_t size; - prefix = f2fs_xattr_prefix(entry->e_name_index, dentry); - if ((void *)(entry) + sizeof(__u32) > last_base_addr || (void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) { f2fs_err(F2FS_I_SB(inode), "list inode (%lu) has corrupted xattr", @@ -590,9 +588,11 @@ ssize_t f2fs_listxattr(struct dentry *de set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK); f2fs_handle_error(F2FS_I_SB(inode), ERROR_CORRUPTED_XATTR); - break; + error = -EFSCORRUPTED; + goto cleanup; } + prefix = f2fs_xattr_prefix(entry->e_name_index, dentry); if (!prefix) continue;