Skip to content

Commit 05d9ea1

Browse files
manasghandatkleikamp
authored andcommitted
jfs: fix array-index-out-of-bounds in diAlloc
Currently there is not check against the agno of the iag while allocating new inodes to avoid fragmentation problem. Added the check which is required. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=79d792676d8ac050949f Signed-off-by: Manas Ghandat <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent 22cad8b commit 05d9ea1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/jfs/jfs_imap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp)
13201320
int diAlloc(struct inode *pip, bool dir, struct inode *ip)
13211321
{
13221322
int rc, ino, iagno, addext, extno, bitno, sword;
1323-
int nwords, rem, i, agno;
1323+
int nwords, rem, i, agno, dn_numag;
13241324
u32 mask, inosmap, extsmap;
13251325
struct inode *ipimap;
13261326
struct metapage *mp;
@@ -1356,6 +1356,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
13561356

13571357
/* get the ag number of this iag */
13581358
agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb));
1359+
dn_numag = JFS_SBI(pip->i_sb)->bmap->db_numag;
1360+
if (agno < 0 || agno > dn_numag)
1361+
return -EIO;
13591362

13601363
if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) {
13611364
/*

0 commit comments

Comments
 (0)