Skip to contentSkip to conversation

f2fs: fix double free of unicode map

PATCH Superseded Hyeongseok Kim 2 participants 3 messages Nov 12, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix double free of unicode map

In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL.
Set NULL after free to prevent double freeing when unmount.

---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +1 -0
index 00eff2f51807..fef22e476c52 100644
@@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 #ifdef CONFIG_UNICODE
 	utf8_unload(sb->s_encoding);
+	sb->s_encoding = NULL;
 #endif
 free_options:
 #ifdef CONFIG_QUOTA
Signature · 8 lines
2.27.0.83.g0313f36



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 16 lines · Hyeongseok Kim

In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL.
Set NULL after free to prevent double freeing when unmount.

---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +0 -0
index 00eff2f51807..fef22e476c52 100644

fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 3924

Quoted 7 lines
fs/f2fs/super.c +1 -0
@@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 #ifdef CONFIG_UNICODE
 	utf8_unload(sb->s_encoding);
+	sb->s_encoding = NULL;
 #endif
 free_options:
 #ifdef CONFIG_QUOTA

This is:

Fixes eca4873ee1b6 ("f2fs: Use generic casefolding support")

Right?

- Eric

author
#2 lore raw
Quoted 26 lines · Eric Biggers
Quoted 16 lines · Hyeongseok Kim

In case of retrying fill_super with skip_recovery, s_encoding for casefold would not be loaded again even though it's already been freed because it's not NULL.
Set NULL after free to prevent double freeing when unmount.

---
  fs/f2fs/super.c | 1 +
  1 file changed, 1 insertion(+)
fs/f2fs/super.c +0 -0
index 00eff2f51807..fef22e476c52 100644

fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 3924

Quoted 7 lines
fs/f2fs/super.c +1 -0
@@ -3918,6 +3918,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
  #ifdef CONFIG_UNICODE
  	utf8_unload(sb->s_encoding);
+	sb->s_encoding = NULL;
  #endif
  free_options:
  #ifdef CONFIG_QUOTA

This is:

Quoted 6 lines
Fixes eca4873ee1b6 ("f2fs: Use generic casefolding support")

Right?

- Eric

Right. Should I add "Fixes" tag and send v2?