Skip to content

Commit d64ff0d

Browse files
ea1daviskleikamp
authored andcommitted
jfs: check if leafidx greater than num leaves per dmap tree
syzbot report a out of bounds in dbSplit, it because dmt_leafidx greater than num leaves per dmap tree, add a checking for dmt_leafidx in dbFindLeaf. Shaggy: Modified sanity check to apply to control pages as well as leaf pages. Reported-and-tested-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=dca05492eff41f604890 Signed-off-by: Edward Adam Davis <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent d6c1b35 commit d64ff0d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/jfs/jfs_dmap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,9 +2944,10 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
29442944
static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
29452945
{
29462946
int ti, n = 0, k, x = 0;
2947-
int max_size;
2947+
int max_size, max_idx;
29482948

29492949
max_size = is_ctl ? CTLTREESIZE : TREESIZE;
2950+
max_idx = is_ctl ? LPERCTL : LPERDMAP;
29502951

29512952
/* first check the root of the tree to see if there is
29522953
* sufficient free space.
@@ -2978,6 +2979,8 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
29782979
*/
29792980
assert(n < 4);
29802981
}
2982+
if (le32_to_cpu(tp->dmt_leafidx) >= max_idx)
2983+
return -ENOSPC;
29812984

29822985
/* set the return to the leftmost leaf describing sufficient
29832986
* free space.

0 commit comments

Comments
 (0)