gregkh at linuxfoundation.org
2023-Jun-17 08:26 UTC
[Ocfs2-devel] Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 4.19-stable tree
This is a note to let you know that I've just added the patch titled ocfs2: fix use-after-free when unmounting read-only filesystem to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ocfs2-fix-use-after-free-when-unmounting-read-only-filesystem.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable at vger.kernel.org> know about it.>From 50d927880e0f90d5cb25e897e9d03e5edacc79a8 Mon Sep 17 00:00:00 2001From: =?UTF-8?q?Lu=C3=ADs=20Henriques?= <ocfs2-devel at oss.oracle.com> Date: Mon, 22 May 2023 11:21:12 +0100 Subject: ocfs2: fix use-after-free when unmounting read-only filesystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Lu?s Henriques <ocfs2-devel at oss.oracle.com> commit 50d927880e0f90d5cb25e897e9d03e5edacc79a8 upstream. It's trivial to trigger a use-after-free bug in the ocfs2 quotas code using fstest generic/452. After a read-only remount, quotas are suspended and ocfs2_mem_dqinfo is freed through ->ocfs2_local_free_info(). When unmounting the filesystem, an UAF access to the oinfo will eventually cause a crash. BUG: KASAN: slab-use-after-free in timer_delete+0x54/0xc0 Read of size 8 at addr ffff8880389a8208 by task umount/669 ... Call Trace: <TASK> ... timer_delete+0x54/0xc0 try_to_grab_pending+0x31/0x230 __cancel_work_timer+0x6c/0x270 ocfs2_disable_quotas.isra.0+0x3e/0xf0 [ocfs2] ocfs2_dismount_volume+0xdd/0x450 [ocfs2] generic_shutdown_super+0xaa/0x280 kill_block_super+0x46/0x70 deactivate_locked_super+0x4d/0xb0 cleanup_mnt+0x135/0x1f0 ... </TASK> Allocated by task 632: kasan_save_stack+0x1c/0x40 kasan_set_track+0x21/0x30 __kasan_kmalloc+0x8b/0x90 ocfs2_local_read_info+0xe3/0x9a0 [ocfs2] dquot_load_quota_sb+0x34b/0x680 dquot_load_quota_inode+0xfe/0x1a0 ocfs2_enable_quotas+0x190/0x2f0 [ocfs2] ocfs2_fill_super+0x14ef/0x2120 [ocfs2] mount_bdev+0x1be/0x200 legacy_get_tree+0x6c/0xb0 vfs_get_tree+0x3e/0x110 path_mount+0xa90/0xe10 __x64_sys_mount+0x16f/0x1a0 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc Freed by task 650: kasan_save_stack+0x1c/0x40 kasan_set_track+0x21/0x30 kasan_save_free_info+0x2a/0x50 __kasan_slab_free+0xf9/0x150 __kmem_cache_free+0x89/0x180 ocfs2_local_free_info+0x2ba/0x3f0 [ocfs2] dquot_disable+0x35f/0xa70 ocfs2_susp_quotas.isra.0+0x159/0x1a0 [ocfs2] ocfs2_remount+0x150/0x580 [ocfs2] reconfigure_super+0x1a5/0x3a0 path_mount+0xc8a/0xe10 __x64_sys_mount+0x16f/0x1a0 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc Link: https://lkml.kernel.org/r/20230522102112.9031-1-lhenriques at suse.de Signed-off-by: Lu?s Henriques <lhenriques at suse.de> Reviewed-by: Joseph Qi <joseph.qi at linux.alibaba.com> Tested-by: Joseph Qi <joseph.qi at linux.alibaba.com> Cc: Mark Fasheh <mark at fasheh.com> Cc: Joel Becker <jlbec at evilplan.org> Cc: Junxiao Bi <junxiao.bi at oracle.com> Cc: Changwei Ge <gechangwei at live.cn> Cc: Gang He <ghe at suse.com> Cc: Jun Piao <piaojun at huawei.com> Cc: <stable at vger.kernel.org> Signed-off-by: Andrew Morton <akpm at linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org> --- fs/ocfs2/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -985,8 +985,10 @@ static void ocfs2_disable_quotas(struct for (type = 0; type < OCFS2_MAXQUOTAS; type++) { if (!sb_has_quota_loaded(sb, type)) continue; - oinfo = sb_dqinfo(sb, type)->dqi_priv; - cancel_delayed_work_sync(&oinfo->dqi_sync_work); + if (!sb_has_quota_suspended(sb, type)) { + oinfo = sb_dqinfo(sb, type)->dqi_priv; + cancel_delayed_work_sync(&oinfo->dqi_sync_work); + } inode = igrab(sb->s_dquot.files[type]); /* Turn off quotas. This will remove all dquot structures from * memory and so they will be automatically synced to global Patches currently in stable-queue which might be from ocfs2-devel at oss.oracle.com are queue-4.19/ocfs2-check-new-file-size-on-fallocate-call.patch queue-4.19/ocfs2-fix-use-after-free-when-unmounting-read-only-filesystem.patch
Seemingly Similar Threads
- Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 4.14-stable tree
- Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 5.4-stable tree
- Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 5.15-stable tree
- Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 5.10-stable tree
- Patch "ocfs2: fix use-after-free when unmounting read-only filesystem" has been added to the 6.1-stable tree