lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20260118192318.44212-1-jiashengjiangcool@gmail.com>
Date: Sun, 18 Jan 2026 19:23:18 +0000
From: Jiasheng Jiang <jiashengjiangcool@...il.com>
To: Mark Fasheh <mark@...heh.com>,
	Joel Becker <jlbec@...lplan.org>,
	Joseph Qi <joseph.qi@...ux.alibaba.com>,
	linux-kernel@...r.kernel.org
Cc: ocfs2-devel@...ts.linux.dev,
	stable@...r.kernel.org,
	Jiasheng Jiang <jiashengjiangcool@...il.com>
Subject: [PATCH] ocfs2: fix potential OOB access in ocfs2_adjust_adjacent_records()

In ocfs2_adjust_adjacent_records(), the code dereferences
right_child_el->l_recs[0] without verifying that the extent list
actually contains any records.

If right_child_el->l_next_free_rec is 0 (e.g., due to a corrupted
filesystem image), this results in an out-of-bounds access when
accessing l_recs[0].e_cpos.

In contrast, ocfs2_adjust_rightmost_records() explicitly validates
that l_next_free_rec is non-zero before accessing records.

This patch adds a check to ensure l_next_free_rec is not zero before
proceeding. If the list is empty, we log an error and return to avoid
reading invalid data.

Fixes: dcd0538ff4e8 ("ocfs2: sparse b-tree support")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>
---
 fs/ocfs2/alloc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 58bf58b68955..bc6f26613e6e 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1974,6 +1974,11 @@ static void ocfs2_adjust_adjacent_records(struct ocfs2_extent_rec *left_rec,
 {
 	u32 left_clusters, right_end;
 
+	if (le16_to_cpu(right_child_el->l_next_free_rec) == 0) {
+		mlog(ML_ERROR, "Extent list has no records\n");
+		return;
+	}
+
 	/*
 	 * Interior nodes never have holes. Their cpos is the cpos of
 	 * the leftmost record in their child list. Their cluster
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ