[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b071e877-334e-b669-e2df-abe4d5927418@kernel.org>
Date: Thu, 4 Nov 2021 16:37:41 +0800
From: Chao Yu <chao@...nel.org>
To: Dongliang Mu <mudongliangabcd@...il.com>,
Jaegeuk Kim <jaegeuk@...nel.org>,
Sahitya Tummala <stummala@...eaurora.org>
Cc: linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] fs: f2fs: fix UAF in f2fs_available_free_memory
On 2021/11/4 16:22, Dongliang Mu wrote:
> if2fs_fill_super
> -> f2fs_build_segment_manager
> -> create_discard_cmd_control
> -> f2fs_start_discard_thread
>
> It invokes kthread_run to create a thread and run issue_discard_thread.
>
> However, if f2fs_build_node_manager fails, the control flow goes to
> free_nm and calls f2fs_destroy_node_manager. This function will free
> sbi->nm_info. However, if issue_discard_thread accesses sbi->nm_info
> after the deallocation, but before the f2fs_stop_discard_thread, it will
> cause UAF(Use-after-free).
>
> -> f2fs_destroy_segment_manager
> -> destroy_discard_cmd_control
> -> f2fs_stop_discard_thread
>
> Fix this by stopping discard thread before f2fs_destroy_node_manager.
>
> Note that, the commit d6d2b491a82e1 introduces the call of
> f2fs_available_free_memory into issue_discard_thread.
>
> Fixes: d6d2b491a82e ("f2fs: allow to change discard policy based on cached discard cmds")
> Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
Reviewed-by: Chao Yu <chao@...nel.org>
Thanks,
Powered by blists - more mailing lists