Linux-f2fs-devel Archive on lore.kernel.org
 help / color / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix use-after-free issue
@ 2020-07-23 10:28 Chao Yu
  2020-07-23 15:26 ` Song Feng
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2020-07-23 10:28 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

From: Li Guifu <bluce.liguifu@huawei.com>

During umount, f2fs_put_super() unregisters procfs entries after
f2fs_destroy_segment_manager(), it may cause use-after-free
issue when umount races with procfs accessing, fix it by relcating
f2fs_unregister_sysfs().

[Chao Yu: change commit title/message a bit]

Signed-off-by: Li Guifu <bluce.liguifu@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 80cb7cd358f8..bf8bd64c8380 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb)
 	int i;
 	bool dropped;
 
+	/* unregister procfs/sysfs entries to avoid race case */
+	f2fs_unregister_sysfs(sbi);
+
 	f2fs_quota_off_umount(sb);
 
 	/* prevent remaining shrinker jobs */
@@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb)
 
 	kvfree(sbi->ckpt);
 
-	f2fs_unregister_sysfs(sbi);
-
 	sb->s_fs_info = NULL;
 	if (sbi->s_chksum_driver)
 		crypto_free_shash(sbi->s_chksum_driver);
-- 
2.26.2



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix use-after-free issue
  2020-07-23 10:28 [f2fs-dev] [PATCH] f2fs: fix use-after-free issue Chao Yu
@ 2020-07-23 15:26 ` Song Feng
  2020-07-24  1:22   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Song Feng @ 2020-07-23 15:26 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

At 2020-07-23 17:28:06, "Chao Yu" <yuchao0@huawei.com> wrote:

>From: Li Guifu <bluce.liguifu@huawei.com>
>
>During umount, f2fs_put_super() unregisters procfs entries after
>f2fs_destroy_segment_manager(), it may cause use-after-free
>issue when umount races with procfs accessing, fix it by relcating
typo issue: relcating -> relocating?
>f2fs_unregister_sysfs().
>
>[Chao Yu: change commit title/message a bit]
>
>Signed-off-by: Li Guifu <bluce.liguifu@huawei.com>
>Reviewed-by: Chao Yu <yuchao0@huawei.com>
>Signed-off-by: Chao Yu <yuchao0@huawei.com>
>---
> fs/f2fs/super.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>index 80cb7cd358f8..bf8bd64c8380 100644
>--- a/fs/f2fs/super.c
>+++ b/fs/f2fs/super.c
>@@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb)
> 	int i;
> 	bool dropped;
> 
>+	/* unregister procfs/sysfs entries to avoid race case */
>+	f2fs_unregister_sysfs(sbi);
>+
> 	f2fs_quota_off_umount(sb);
> 
> 	/* prevent remaining shrinker jobs */
>@@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb)
> 
> 	kvfree(sbi->ckpt);
> 
>-	f2fs_unregister_sysfs(sbi);
>-
> 	sb->s_fs_info = NULL;
> 	if (sbi->s_chksum_driver)
> 		crypto_free_shash(sbi->s_chksum_driver);
>-- 
>2.26.2
>
>
>
>_______________________________________________
>Linux-f2fs-devel mailing list
>Linux-f2fs-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
please check typo issue for comment: relcating->relocating?
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix use-after-free issue
  2020-07-23 15:26 ` Song Feng
@ 2020-07-24  1:22   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2020-07-24  1:22 UTC (permalink / raw)
  To: Song Feng; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

Hi Feng,

Thanks for the reminder. :)

Jaegeuk, could you please fix this while merging.

Thanks,

On 2020/7/23 23:26, Song Feng wrote:
> At 2020-07-23 17:28:06, "Chao Yu" <yuchao0@huawei.com> wrote:
> 
>> From: Li Guifu <bluce.liguifu@huawei.com>
>>
>> During umount, f2fs_put_super() unregisters procfs entries after
>> f2fs_destroy_segment_manager(), it may cause use-after-free
>> issue when umount races with procfs accessing, fix it by relcating
> typo issue: relcating -> relocating?
>> f2fs_unregister_sysfs().
>>
>> [Chao Yu: change commit title/message a bit]
>>
>> Signed-off-by: Li Guifu <bluce.liguifu@huawei.com>
>> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> fs/f2fs/super.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 80cb7cd358f8..bf8bd64c8380 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb)
>> 	int i;
>> 	bool dropped;
>>
>> +	/* unregister procfs/sysfs entries to avoid race case */
>> +	f2fs_unregister_sysfs(sbi);
>> +
>> 	f2fs_quota_off_umount(sb);
>>
>> 	/* prevent remaining shrinker jobs */
>> @@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb)
>>
>> 	kvfree(sbi->ckpt);
>>
>> -	f2fs_unregister_sysfs(sbi);
>> -
>> 	sb->s_fs_info = NULL;
>> 	if (sbi->s_chksum_driver)
>> 		crypto_free_shash(sbi->s_chksum_driver);
>> -- 
>> 2.26.2
>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> please check typo issue for comment: relcating->relocating?
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 10:28 [f2fs-dev] [PATCH] f2fs: fix use-after-free issue Chao Yu
2020-07-23 15:26 ` Song Feng
2020-07-24  1:22   ` Chao Yu

Linux-f2fs-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-f2fs-devel/0 linux-f2fs-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-f2fs-devel linux-f2fs-devel/ https://lore.kernel.org/linux-f2fs-devel \
		linux-f2fs-devel@lists.sourceforge.net
	public-inbox-index linux-f2fs-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/net.sourceforge.lists.linux-f2fs-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git