mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-28 05:24:47 +08:00
jfs: fix array-index-out-of-bounds in diAlloc
[ Upstream commit 05d9ea1ceb
]
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: syzbot+79d792676d8ac050949f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=79d792676d8ac050949f
Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
da3da5e1e6
commit
64f062baf2
@ -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 diAlloc(struct inode *pip, bool dir, struct inode *ip)
|
||||||
{
|
{
|
||||||
int rc, ino, iagno, addext, extno, bitno, sword;
|
int rc, ino, iagno, addext, extno, bitno, sword;
|
||||||
int nwords, rem, i, agno;
|
int nwords, rem, i, agno, dn_numag;
|
||||||
u32 mask, inosmap, extsmap;
|
u32 mask, inosmap, extsmap;
|
||||||
struct inode *ipimap;
|
struct inode *ipimap;
|
||||||
struct metapage *mp;
|
struct metapage *mp;
|
||||||
@ -1356,6 +1356,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
|
|||||||
|
|
||||||
/* get the ag number of this iag */
|
/* get the ag number of this iag */
|
||||||
agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb));
|
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])) {
|
if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user