Skip to content

Commit 1bb933f

Browse files
Lukas Czernertytso
authored andcommitted
ext4: fix possible use-after-free in ext4_remove_li_request()
We need to take reference to the s_li_request after we take a mutex, because it might be freed since then, hence result in accessing old already freed memory. Also we should protect the whole ext4_remove_li_request() because ext4_li_info might be in the process of being freed in ext4_lazyinit_thread(). Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
1 parent 51ce651 commit 1bb933f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎fs/ext4/super.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,14 +2735,16 @@ static void ext4_remove_li_request(struct ext4_li_request *elr)
27352735

27362736
static void ext4_unregister_li_request(struct super_block *sb)
27372737
{
2738-
struct ext4_li_request *elr = EXT4_SB(sb)->s_li_request;
2739-
2740-
if (!ext4_li_info)
2738+
mutex_lock(&ext4_li_mtx);
2739+
if (!ext4_li_info) {
2740+
mutex_unlock(&ext4_li_mtx);
27412741
return;
2742+
}
27422743

27432744
mutex_lock(&ext4_li_info->li_list_mtx);
2744-
ext4_remove_li_request(elr);
2745+
ext4_remove_li_request(EXT4_SB(sb)->s_li_request);
27452746
mutex_unlock(&ext4_li_info->li_list_mtx);
2747+
mutex_unlock(&ext4_li_mtx);
27462748
}
27472749

27482750
static struct task_struct *ext4_lazyinit_task;

0 commit comments

Comments
 (0)