summaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2011-05-20 19:55:29 +0200
committerTheodore Ts'o <tytso@mit.edu>2011-05-20 19:55:29 +0200
commit1bb933fb1fa8e4cb337a0d5dfd2ff4c0dc2073e8 (patch)
treed03bbc0de028862fb9df1d7941a03103150d69de /fs/ext4/super.c
parentext4: fix the mount option "init_itable=n" to work as expected for n=0 (diff)
downloadlinux-1bb933fb1fa8e4cb337a0d5dfd2ff4c0dc2073e8.tar.xz
linux-1bb933fb1fa8e4cb337a0d5dfd2ff4c0dc2073e8.zip
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>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index fd51a4a266b6..ed5e80ef48c4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2735,14 +2735,16 @@ static void ext4_remove_li_request(struct ext4_li_request *elr)
static void ext4_unregister_li_request(struct super_block *sb)
{
- struct ext4_li_request *elr = EXT4_SB(sb)->s_li_request;
-
- if (!ext4_li_info)
+ mutex_lock(&ext4_li_mtx);
+ if (!ext4_li_info) {
+ mutex_unlock(&ext4_li_mtx);
return;
+ }
mutex_lock(&ext4_li_info->li_list_mtx);
- ext4_remove_li_request(elr);
+ ext4_remove_li_request(EXT4_SB(sb)->s_li_request);
mutex_unlock(&ext4_li_info->li_list_mtx);
+ mutex_unlock(&ext4_li_mtx);
}
static struct task_struct *ext4_lazyinit_task;