Skip to content

Commit a530462

Browse files
YunDingLabkleikamp
authored andcommitted
jfs: prevent NULL deref in diFree
Add validation check for JFS_IP(ipimap)->i_imap to prevent a NULL deref in diFree since diFree uses it without do any validations. When function jfs_mount calls diMount to initialize fileset inode allocation map, it can fail and JFS_IP(ipimap)->i_imap won't be initialized. Then it calls diFreeSpecial to close fileset inode allocation map inode and it will flow into jfs_evict_inode. Function jfs_evict_inode just validates JFS_SBI(inode->i_sb)->ipimap, then calls diFree. diFree use JFS_IP(ipimap)->i_imap directly, then it will cause a NULL deref. Reported-by: TCS Robot <tcs_robot@tencent.com> Signed-off-by: Haimin Zhang <tcs_kernel@tencent.com> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
1 parent 2cc7cc0 commit a530462

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/jfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void jfs_evict_inode(struct inode *inode)
146146
dquot_initialize(inode);
147147

148148
if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
149+
struct inode *ipimap = JFS_SBI(inode->i_sb)->ipimap;
149150
truncate_inode_pages_final(&inode->i_data);
150151

151152
if (test_cflag(COMMIT_Freewmap, inode))
152153
jfs_free_zero_link(inode);
153154

154-
if (JFS_SBI(inode->i_sb)->ipimap)
155+
if (ipimap && JFS_IP(ipimap)->i_imap)
155156
diFree(inode);
156157

157158
/*

0 commit comments

Comments
 (0)