]> Git Repo - linux.git/commitdiff
jfs: fix array-index-out-of-bounds in diAlloc
authorManas Ghandat <[email protected]>
Wed, 4 Oct 2023 07:40:40 +0000 (13:10 +0530)
committerDave Kleikamp <[email protected]>
Wed, 4 Oct 2023 14:18:03 +0000 (09:18 -0500)
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]>
fs/jfs/jfs_imap.c

index 923a58422c4611ccf1b90d2700d7423debec31cf..1b267eec3f367c26910631da3bd0d708d0213d65 100644 (file)
@@ -1320,7 +1320,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp)
 int diAlloc(struct inode *pip, bool dir, struct inode *ip)
 {
        int rc, ino, iagno, addext, extno, bitno, sword;
-       int nwords, rem, i, agno;
+       int nwords, rem, i, agno, dn_numag;
        u32 mask, inosmap, extsmap;
        struct inode *ipimap;
        struct metapage *mp;
@@ -1356,6 +1356,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
 
        /* get the ag number of this iag */
        agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb));
+       dn_numag = JFS_SBI(pip->i_sb)->bmap->db_numag;
+       if (agno < 0 || agno > dn_numag)
+               return -EIO;
 
        if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) {
                /*
This page took 0.050148 seconds and 4 git commands to generate.