All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference
@ 2022-10-17 10:04 ` Hoi Pok Wu
  0 siblings, 0 replies; 4+ messages in thread
From: Hoi Pok Wu @ 2022-10-17 10:04 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: Hoi Pok Wu, linux-f2fs-devel, linux-kernel,
	syzbot+035a381ea1afb63f098d, syzkaller-bugs

Pointer discard_thread is pointing to nowhere, using IS_ERR prevents the
situation. IS_ERR also seen being used throughout the file.

Link: https://syzkaller.appspot.com/bug?id=9499bc6574cea5940e48199c2fd0732d9b11e5e1
Reported-by: syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com
Signed-off-by: Hoi Pok Wu <wuhoipok@gmail.com>
---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index acf3d3fa4363..79978b7206b5 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1634,7 +1634,8 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
 		struct task_struct *discard_thread = dcc->f2fs_issue_discard;
 
 		dcc->f2fs_issue_discard = NULL;
-		kthread_stop(discard_thread);
+		if (!IS_ERR(discard_thread))
+			kthread_stop(discard_thread);
 	}
 }
 
-- 
2.38.0


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

* [f2fs-dev] [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference
@ 2022-10-17 10:04 ` Hoi Pok Wu
  0 siblings, 0 replies; 4+ messages in thread
From: Hoi Pok Wu @ 2022-10-17 10:04 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: Hoi Pok Wu, syzkaller-bugs, linux-kernel,
	syzbot+035a381ea1afb63f098d, linux-f2fs-devel

Pointer discard_thread is pointing to nowhere, using IS_ERR prevents the
situation. IS_ERR also seen being used throughout the file.

Link: https://syzkaller.appspot.com/bug?id=9499bc6574cea5940e48199c2fd0732d9b11e5e1
Reported-by: syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com
Signed-off-by: Hoi Pok Wu <wuhoipok@gmail.com>
---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index acf3d3fa4363..79978b7206b5 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1634,7 +1634,8 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
 		struct task_struct *discard_thread = dcc->f2fs_issue_discard;
 
 		dcc->f2fs_issue_discard = NULL;
-		kthread_stop(discard_thread);
+		if (!IS_ERR(discard_thread))
+			kthread_stop(discard_thread);
 	}
 }
 
-- 
2.38.0



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

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

* Re: [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference
  2022-10-17 10:04 ` [f2fs-dev] " Hoi Pok Wu
@ 2022-10-17 12:23   ` Chao Yu
  -1 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2022-10-17 12:23 UTC (permalink / raw)
  To: Hoi Pok Wu, jaegeuk
  Cc: linux-f2fs-devel, linux-kernel, syzbot+035a381ea1afb63f098d,
	syzkaller-bugs

On 2022/10/17 18:04, Hoi Pok Wu wrote:
> Pointer discard_thread is pointing to nowhere, using IS_ERR prevents the
> situation. IS_ERR also seen being used throughout the file.

I guess below patch can fix this issue from root cause?

https://lore.kernel.org/linux-f2fs-devel/20221013155628.434671-1-chao@kernel.org/T/#u

Thanks,

> 
> Link: https://syzkaller.appspot.com/bug?id=9499bc6574cea5940e48199c2fd0732d9b11e5e1
> Reported-by: syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com
> Signed-off-by: Hoi Pok Wu <wuhoipok@gmail.com>
> ---
>   fs/f2fs/segment.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index acf3d3fa4363..79978b7206b5 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1634,7 +1634,8 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
>   		struct task_struct *discard_thread = dcc->f2fs_issue_discard;
>   
>   		dcc->f2fs_issue_discard = NULL;
> -		kthread_stop(discard_thread);
> +		if (!IS_ERR(discard_thread))
> +			kthread_stop(discard_thread);
>   	}
>   }
>   

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

* Re: [f2fs-dev] [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference
@ 2022-10-17 12:23   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2022-10-17 12:23 UTC (permalink / raw)
  To: Hoi Pok Wu, jaegeuk
  Cc: syzkaller-bugs, linux-kernel, syzbot+035a381ea1afb63f098d,
	linux-f2fs-devel

On 2022/10/17 18:04, Hoi Pok Wu wrote:
> Pointer discard_thread is pointing to nowhere, using IS_ERR prevents the
> situation. IS_ERR also seen being used throughout the file.

I guess below patch can fix this issue from root cause?

https://lore.kernel.org/linux-f2fs-devel/20221013155628.434671-1-chao@kernel.org/T/#u

Thanks,

> 
> Link: https://syzkaller.appspot.com/bug?id=9499bc6574cea5940e48199c2fd0732d9b11e5e1
> Reported-by: syzbot+035a381ea1afb63f098d@syzkaller.appspotmail.com
> Signed-off-by: Hoi Pok Wu <wuhoipok@gmail.com>
> ---
>   fs/f2fs/segment.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index acf3d3fa4363..79978b7206b5 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1634,7 +1634,8 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
>   		struct task_struct *discard_thread = dcc->f2fs_issue_discard;
>   
>   		dcc->f2fs_issue_discard = NULL;
> -		kthread_stop(discard_thread);
> +		if (!IS_ERR(discard_thread))
> +			kthread_stop(discard_thread);
>   	}
>   }
>   


_______________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2022-10-17 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17 10:04 [PATCH] fs: f2fs: fix kernel discard_thread NULL dereference Hoi Pok Wu
2022-10-17 10:04 ` [f2fs-dev] " Hoi Pok Wu
2022-10-17 12:23 ` Chao Yu
2022-10-17 12:23   ` [f2fs-dev] " Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.