jfs: fix array-index-out-of-bounds in diAlloc
PATCH v2 1/1 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]
Signed-off-by Manas Ghandat <[email protected]>
---
V1 -> V2 : Added check for higher bound of agno
fs/jfs/jfs_imap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/jfs/jfs_imap.c +4 -1
@@ -1319,7 +1319,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;
@@ -1355,6 +1355,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])) {/*
Signature · 6 lines
2.37.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Dave Kleikamp
AppliedQuoted 3 lines · Manas Ghandat
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.
Applied to jfs-next
Thanks,
Shaggy
Quoted 23 lines
Reported-by [email protected]Signed-off-by Manas Ghandat <[email protected]>---
V1 -> V2 : Added check for higher bound of agnofs/jfs/jfs_imap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/jfs/jfs_imap.c +1
-1@@ -1319,7 +1319,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;
fs/jfs/jfs_imap.c int diAlloc(struct inode *pip, bool dir, struct inode *ip) · line 1363
Quoted 9 lines
fs/jfs/jfs_imap.c +3
-0@@ -1355,6 +1355,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])) {/*
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees