From: Greg KH <gregkh@linuxfoundation.org>
To: Zheng Yejian <zhengyejian1@huawei.com>
Cc: rostedt@goodmis.org, stable@vger.kernel.org
Subject: Re: [PATCH 5.10] tracing: Fix memory leak of iter->temp when reading trace_pipe
Date: Mon, 24 Jul 2023 08:30:01 +0200 [thread overview]
Message-ID: <2023072454-policy-whomever-6ecc@gregkh> (raw)
In-Reply-To: <20230724021656.3472116-1-zhengyejian1@huawei.com>
On Mon, Jul 24, 2023 at 10:16:56AM +0800, Zheng Yejian wrote:
> commit d5a821896360cc8b93a15bd888fabc858c038dc0 upstream.
>
> kmemleak reports:
> unreferenced object 0xffff88814d14e200 (size 256):
> comm "cat", pid 336, jiffies 4294871818 (age 779.490s)
> hex dump (first 32 bytes):
> 04 00 01 03 00 00 00 00 08 00 00 00 00 00 00 00 ................
> 0c d8 c8 9b ff ff ff ff 04 5a ca 9b ff ff ff ff .........Z......
> backtrace:
> [<ffffffff9bdff18f>] __kmalloc+0x4f/0x140
> [<ffffffff9bc9238b>] trace_find_next_entry+0xbb/0x1d0
> [<ffffffff9bc9caef>] trace_print_lat_context+0xaf/0x4e0
> [<ffffffff9bc94490>] print_trace_line+0x3e0/0x950
> [<ffffffff9bc95499>] tracing_read_pipe+0x2d9/0x5a0
> [<ffffffff9bf03a43>] vfs_read+0x143/0x520
> [<ffffffff9bf04c2d>] ksys_read+0xbd/0x160
> [<ffffffff9d0f0edf>] do_syscall_64+0x3f/0x90
> [<ffffffff9d2000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
>
> when reading file 'trace_pipe', 'iter->temp' is allocated or relocated
> in trace_find_next_entry() but not freed before 'trace_pipe' is closed.
>
> To fix it, free 'iter->temp' in tracing_release_pipe().
>
> Link: https://lore.kernel.org/linux-trace-kernel/20230713141435.1133021-1-zhengyejian1@huawei.com
>
> Cc: stable@vger.kernel.org
> Fixes: ff895103a84ab ("tracing: Save off entry when peeking at next entry")
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> [Fix conflict due to lack of 649e72070cbbb8600eb823833e4748f5a0815116]
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> ---
> kernel/trace/trace.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 70526400e05c..8d005c7ccfae 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -6250,6 +6250,7 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
> mutex_unlock(&trace_types_lock);
>
> free_cpumask_var(iter->started);
> + kfree(iter->temp);
> mutex_destroy(&iter->mutex);
> kfree(iter);
>
> --
> 2.25.1
>
Now queued up, thanks.
greg k-h
prev parent reply other threads:[~2023-07-24 6:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 14:22 FAILED: patch "[PATCH] tracing: Fix memory leak of iter->temp when reading" failed to apply to 5.10-stable tree gregkh
2023-07-24 2:16 ` [PATCH 5.10] tracing: Fix memory leak of iter->temp when reading trace_pipe Zheng Yejian
2023-07-24 6:30 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2023072454-policy-whomever-6ecc@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
--cc=zhengyejian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.