Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793215459; b=dHL5Y/fHhXCT9BUaFJhc1O1goPUa2gIoSh7tt6vlcG3lnEITF7b06yDq6UtmCCLF0wMq shYACTseu+rcq27ks7bSf2xA8eNueBpmjU9ACD2iIXMaIIartihICubz07WQHtZQzegsk VcmrM6Qv5lSDjm7VuDg9Y5tLCtNk6CE+qHJDONK7Wh2HWn4J4znl/rc53qSlZpKB3ikVK RhxTH8Of8Tl9Wljy5vLWipHpLfnfSUFleOBhZ3jov2Jd78R7xZUXNsZ+8UuBZJwjLNE3C qNsDhMiWMKAZgx4bzUjr76BXSIh6BQRkRmoAebcBzYP7+KHCMXqKUfgOJR9Wi6zyLyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793215459; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=RWfUbeFKn3jH8AlURrkYr11cujKHtXcSJ+TzCt+r8R4=; b=HmUwoZzaQKPUnBwaX88iS5wr05Zny+6U27EoEEr/UUPU7B0TvmB+HFq67mMx9kliGeMV jfkp+0AlWnAfTBZk5vo6RGSBzlI2zdIwErLgq1rWeoFvTuPJ/soXNG9nTYStLkKWL0HDz OTFBGwT0+tRnMRJn23F5/Y6f0XoVGjMSa3rOdfmycxciQ14eSB3MF2Odvl0pG+f6oPUDt CmRdo+ir5OmZ/5DRqT2nTjfnbPTjCxM6pYmyX/ok5ox8EeXN9rd6UyqsBckx3fkl5QD7K NDJcTQOTnTJGziUDXoRJec4NMYmtDqVbxH+fNNbKst51sVRc4y9cQMfOBHA7oiJO0Gw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZwThc99m; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE1B4606A31C; Wed, 28 Oct 2026 19:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZwThc99m Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2338B1F01825; Wed, 28 Oct 2026 19:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793215458; bh=RWfUbeFKn3jH8AlURrkYr11cujKHtXcSJ+TzCt+r8R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZwThc99m/kBUT8hGYMBQRKDMuZLu87x580YSsUAvZBgJbW4Ze5dQK45bLTXnYFiHa D7LyQwPO+rp9/xQyCn/v+JHxgzlSKF4kzrtY6FdOjeEd9Rv8hkofKTATQFYloje01x A5zEWv9J86Tf3SlOcPgZllcSA294j5Es8ey1bYDE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Bridges , syzbot+be16e33db01e6644db7a@syzkaller.appspotmail.com, Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Heming Zhao , Andrew Morton , Sasha Levin Subject: [PATCH 6.1 1217/1887] ocfs2: fix UBSAN array-index-out-of-bounds in ocfs2_sum_rightmost_rec Date: Wed, 28 Oct 2026 17:55:13 +0100 Message-ID: <20261028170527.103641576@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Bridges [ Upstream commit 452a8467be8143747292218212671deeb186d2ae ] [BUG] On-disk corruption setting l_next_free_rec to 0 in an inode's embedded extent list triggers a UBSAN panic on the next write to that file. [CAUSE] ocfs2_sum_rightmost_rec() computes i = le16_to_cpu(el->l_next_free_rec) - 1 and accesses el->l_recs[i] without validating i. When l_next_free_rec is 0, i becomes -1; when l_next_free_rec exceeds l_count, i falls past the end of the array. Either case violates the __counted_by_le(l_count) annotation on l_recs[] and triggers UBSAN. [FIX] Validate the inode's embedded extent list when the inode is read, in ocfs2_validate_inode_block(): l_count must be non-zero and no larger than the inode block can hold, and l_next_free_rec must not exceed l_count. A corrupt list is rejected at read time, before the b-tree code can index l_recs[] out of bounds. Link: https://lore.kernel.org/ain_780qc0P4ypNd@dev Signed-off-by: Ian Bridges Reported-by: syzbot+be16e33db01e6644db7a@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=be16e33db01e6644db7a Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- fs/ocfs2/inode.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index c55eb77e5d87d..73b2dda9ffe7b 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -1609,6 +1609,38 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } + if (ocfs2_dinode_has_extents(di)) { + struct ocfs2_extent_list *el = &di->id2.i_list; + u16 count = le16_to_cpu(el->l_count); + u16 next_free = le16_to_cpu(el->l_next_free_rec); + + if (count == 0) { + rc = ocfs2_error(sb, + "Invalid dinode %llu: extent list l_count is zero\n", + (unsigned long long)bh->b_blocknr); + goto bail; + } + /* + * The exact capacity depends on i_xattr_inline_size, another + * unvalidated on-disk field. Inline xattrs only shrink the + * list, so the no-xattr maximum is a safe upper bound that a + * valid l_count never exceeds. + */ + if (count > ocfs2_extent_recs_per_inode(sb)) { + rc = ocfs2_error(sb, + "Invalid dinode %llu: extent list l_count %u exceeds max %u\n", + (unsigned long long)bh->b_blocknr, count, + ocfs2_extent_recs_per_inode(sb)); + goto bail; + } + if (next_free > count) { + rc = ocfs2_error(sb, + "Invalid dinode %llu: extent list l_next_free_rec %u exceeds l_count %u\n", + (unsigned long long)bh->b_blocknr, next_free, count); + goto bail; + } + } + rc = 0; bail: -- 2.53.0