jfs: fix uaf in jfs_evict_inode
authorEdward Adam Davis <eadavis@qq.com>
Tue, 31 Oct 2023 05:39:04 +0000 (13:39 +0800)
committerDave Kleikamp <dave.kleikamp@oracle.com>
Tue, 21 Nov 2023 21:26:33 +0000 (15:26 -0600)
When the execution of diMount(ipimap) fails, the object ipimap that has been
released may be accessed in diFreeSpecial(). Asynchronous ipimap release occurs
when rcu_core() calls jfs_free_node().

Therefore, when diMount(ipimap) fails, sbi->ipimap should not be initialized as
ipimap.

Reported-and-tested-by: syzbot+01cf2dbcbe2022454388@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
fs/jfs/jfs_mount.c

index 415eb65a36ffcbc31b28fd59c7756f7fd3416c6e..9b5c6a20b30c8323f09aefcce6b4ff0482c9b2dc 100644 (file)
@@ -172,15 +172,15 @@ int jfs_mount(struct super_block *sb)
        }
        jfs_info("jfs_mount: ipimap:0x%p", ipimap);
 
-       /* map further access of per fileset inodes by the fileset inode */
-       sbi->ipimap = ipimap;
-
        /* initialize fileset inode allocation map */
        if ((rc = diMount(ipimap))) {
                jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
                goto err_ipimap;
        }
 
+       /* map further access of per fileset inodes by the fileset inode */
+       sbi->ipimap = ipimap;
+
        return rc;
 
        /*