jfs: validate dmap parameters in dbMount() and slot chains in jfs_dtree.c
Subsystems (2)
PATCH 1/1 jfs: validate dmap parameters in dbMount() and slot chains in jfs_dtree.c
Fix two filesystem corruption crashes in fs/jfs/:
1. In dbMount() (fs/jfs/jfs_dmap.c), validate db_mapsize > 0, db_numag <= MAXAG, db_agheight <= MAX_AGHEIGHT, and db_agwidth > 0 to prevent out-of-bounds array indexing on bmp->db_agfree[] and shift UB.
2. In check_dtroot(), check_dtpage(), and jfs_readdir() (fs/jfs/jfs_dtree.c), validate directory slot continuation indices to prevent cyclic or out-of-bounds slot walks.
---
fs/jfs/jfs_dmap.c +2 -1
@@ -288,7 +288,8 @@ int dbMount(struct inode *ipbmap) (bmp->db_agstart > (CTLTREESIZE -1 - bmp->db_agwidth * (MAXAG -1 ))) || (bmp->db_agl2size >L2MAXL2SIZE -L2MAXAG ) || (bmp->db_agl2size <0 ) || - ((bmp->db_mapsize - 1) >> bmp->db_agl2size) > MAXAG) { + (bmp->db_mapsize <=0 ) || + (((bmp->db_mapsize - 1) >> bmp->db_agl2size) >= MAXAG)) { err = -EINVAL; goto err_release_metapage; }
fs/jfs/jfs_dtree.c +47 -0
83 lines not on this page · raw message