Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocfs2: validate l_tree_depth to avoid out-of-bounds access

The l_tree_depth field is 16-bit (__le16), but the actual maximum depth is
limited to OCFS2_MAX_PATH_DEPTH.

Add a check to prevent out-of-bounds access if l_tree_depth has an invalid
value, which may occur when reading from a corrupted mounted disk [1].

Link: https://lkml.kernel.org/r/20250214084908.736528-1-kovalev@altlinux.org
Fixes: ccd979bdbce9 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
Reported-by: syzbot+66c146268dc88f4341fd@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=66c146268dc88f4341fd [1]
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Kurt Hackel <kurt.hackel@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Vasiliy Kovalev <kovalev@altlinux.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Vasiliy Kovalev and committed by
Andrew Morton
a406aff8 b4dc0bee

+8
+8
fs/ocfs2/alloc.c
··· 1803 1803 1804 1804 el = root_el; 1805 1805 while (el->l_tree_depth) { 1806 + if (unlikely(le16_to_cpu(el->l_tree_depth) >= OCFS2_MAX_PATH_DEPTH)) { 1807 + ocfs2_error(ocfs2_metadata_cache_get_super(ci), 1808 + "Owner %llu has invalid tree depth %u in extent list\n", 1809 + (unsigned long long)ocfs2_metadata_cache_owner(ci), 1810 + le16_to_cpu(el->l_tree_depth)); 1811 + ret = -EROFS; 1812 + goto out; 1813 + } 1806 1814 if (le16_to_cpu(el->l_next_free_rec) == 0) { 1807 1815 ocfs2_error(ocfs2_metadata_cache_get_super(ci), 1808 1816 "Owner %llu has empty extent list at depth %u\n",