* [PATCH] eventfs: Test for dentries array allocated in eventfs_release()
@ 2023-09-30 13:01 Steven Rostedt
2023-09-30 15:12 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2023-09-30 13:01 UTC (permalink / raw)
To: LKML; +Cc: Linux trace kernel, Masami Hiramatsu, Mark Rutland
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
The dcache_dir_open_wrapper() could be called when a dynamic event is
being deleted leaving a dentry with no children. In this case the
dlist->dentries array will never be allocated. This needs to be checked
for in eventfs_release(), otherwise it will trigger a NULL pointer
dereference.
Fixes: ef36b4f92868 ("eventfs: Remember what dentries were created on dir open")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
fs/tracefs/event_inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 5f1714089884..8c8d64e76103 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -421,7 +421,7 @@ static int eventfs_release(struct inode *inode, struct file *file)
if (WARN_ON_ONCE(!dlist))
return -EINVAL;
- for (i = 0; dlist->dentries[i]; i++) {
+ for (i = 0; dlist->dentries && dlist->dentries[i]; i++) {
dput(dlist->dentries[i]);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] eventfs: Test for dentries array allocated in eventfs_release()
2023-09-30 13:01 [PATCH] eventfs: Test for dentries array allocated in eventfs_release() Steven Rostedt
@ 2023-09-30 15:12 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2023-09-30 15:12 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, Linux trace kernel, Masami Hiramatsu, Mark Rutland
On Sat, 30 Sep 2023 09:01:06 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> The dcache_dir_open_wrapper() could be called when a dynamic event is
> being deleted leaving a dentry with no children. In this case the
> dlist->dentries array will never be allocated. This needs to be checked
> for in eventfs_release(), otherwise it will trigger a NULL pointer
> dereference.
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you,
>
> Fixes: ef36b4f92868 ("eventfs: Remember what dentries were created on dir open")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> fs/tracefs/event_inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> index 5f1714089884..8c8d64e76103 100644
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c
> @@ -421,7 +421,7 @@ static int eventfs_release(struct inode *inode, struct file *file)
> if (WARN_ON_ONCE(!dlist))
> return -EINVAL;
>
> - for (i = 0; dlist->dentries[i]; i++) {
> + for (i = 0; dlist->dentries && dlist->dentries[i]; i++) {
> dput(dlist->dentries[i]);
> }
>
> --
> 2.40.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-30 15:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-30 13:01 [PATCH] eventfs: Test for dentries array allocated in eventfs_release() Steven Rostedt
2023-09-30 15:12 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox