CVE-2026-99820: ocfs2: fix array out of bound access in __ocfs2_find_path()
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: fix array out of bound access in ocfs2findpath()
ocfs2findpath() walks down the extent tree and records path by calling findpathins(), which appends entry to path->pnode[]. It only has 5 spots.
A corrupted ocfs2 image whose extent block is pointing to itself causes ocfs2findpath() descent endlessly, writing past the end of path->pnode[] array.
UBSAN: array-index-out-of-bounds in fs/ocfs2/alloc.c:677:14 index 5 is out of range for type 'ocfs2pathitem [5]' Call Trace: <TASK> findpathins (fs/ocfs2/alloc.c:677 fs/ocfs2/alloc.c:1914) ocfs2findpath.constprop.0 (fs/ocfs2/alloc.c:1882) ocfs2committruncate (fs/ocfs2/alloc.c:1924 fs/ocfs2/alloc.c:7286) ocfs2truncatefile (fs/ocfs2/file.c:515) ocfs2setattr (fs/ocfs2/file.c:1224) notifychange (fs/attr.c:556) dotruncate (fs/open.c:68) doftruncate (fs/open.c:194 (discriminator 1)) ksysftruncate (fs/open.c:206) x64sysftruncate (fs/open.c:211 fs/open.c:209 fs/open.c:209)
Commit a406aff8c051 ("ocfs2: validate ltreedepth to avoid out-of-bounds access") already restricts el->ltreedepth to be less than OCFS2MAXPATHDEPTH, which is equal to 5. However, does not handle the infinite descent case.
Check if the el->ltreedepth decreases on each descent. Maximum descents are restricted to 4 and the path->pnode[] array does not overflow.