Skip to content

Commit c214006

Browse files
ArnaudLcmkleikamp
authored andcommitted
jfs: upper bound check of tree index in dbAllocAG
When computing the tree index in dbAllocAG, we never check if we are out of bounds realative to the size of the stree. This could happen in a scenario where the filesystem metadata are corrupted. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=cffd18309153948f3c3e Tested-by: [email protected] Signed-off-by: Arnaud Lecomte <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent bc9ff19 commit c214006

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/jfs/jfs_dmap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,12 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results)
13891389
(1 << (L2LPERCTL - (bmp->db_agheight << 1))) / bmp->db_agwidth;
13901390
ti = bmp->db_agstart + bmp->db_agwidth * (agno & (agperlev - 1));
13911391

1392+
if (ti < 0 || ti >= le32_to_cpu(dcp->nleafs)) {
1393+
jfs_error(bmp->db_ipbmap->i_sb, "Corrupt dmapctl page\n");
1394+
release_metapage(mp);
1395+
return -EIO;
1396+
}
1397+
13921398
/* dmap control page trees fan-out by 4 and a single allocation
13931399
* group may be described by 1 or 2 subtrees within the ag level
13941400
* dmap control page, depending upon the ag size. examine the ag's

0 commit comments

Comments
 (0)