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 5A0603161AD; Thu, 16 Jul 2026 14:20:22 +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=1784211623; cv=none; b=Ej0Hb/J/YKKlxnGnPjp07t6SWTqfYiXJl+4aWLBymXE9HRMAuruChkaBbu+ngaZs/JQunnlG/oxKNDdc6p3w1o0F2ReUtmJSMjiZTNAAjD75Kag902FDQ3XWZmd0Nx/ODRG7mTCL7G55uLPojpS/Qe8BJATo6DJUBjFJiyKLi6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784211623; c=relaxed/simple; bh=tv51XpGlRmgBxzkdnMNUjxHPh7QEqaBR9BvOK3kLPcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UnycR0LJVIEasl9eh+0Gg/UoyeD0Nv9YxjiyuBx6xEp8MP+HEx5dkVoUTpblVaf09zv+OzqIOBdS2X0o293Mr6B2Nzgb9Lxycd1QR65RWZE4XPfKJ+RLdLFzoUDVv0j3Erj4iSIzVHYW8kkJ9hwEAiwlUcymZUhUnHweXF2wrSc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lLVHC5k4; 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="lLVHC5k4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7FEE1F000E9; Thu, 16 Jul 2026 14:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784211622; bh=Qw1dmwAnS9w9/+Y31zB/VPM+ERlF071KT6q/jdwROOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lLVHC5k4ZaLt21CXK1nx+veN8k55l6jOJWIQEAv0SKmRxwSV8BBXOe1Sk2AAizCau FGiaqZQyIQfx7/P+5K3EpecQnbrdUpzb3RpXkg0GeAcGLsmLhf9YYuJ76HXOMsLJ/2 SEJhCjbIYxqg/2i8Pt8MUjm4yitOPqXGbllw12NY= 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.12 018/349] f2fs: fix listxattr handling of corrupted xattr entries Date: Thu, 16 Jul 2026 15:29:12 +0200 Message-ID: <20260716133033.703510522@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133033.287196923@linuxfoundation.org> References: <20260716133033.287196923@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.12-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;