* Re: [PATCH] trace: fix potenial dangerous pointer
[not found] <20201124165205.GA23937@rlk>
@ 2020-11-24 17:05 ` Steven Rostedt
2020-11-24 17:09 ` Tejun Heo
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2020-11-24 17:05 UTC (permalink / raw)
To: Hui Su
Cc: mingo, jack, akpm, neilb, tj, trond.myklebust, liuzhiqiang26,
tytso, cai, linux-kernel
On Wed, 25 Nov 2020 00:52:05 +0800
Hui Su <sh_def@163.com> wrote:
> The bdi_dev_name() returns a char [64], and
> the __entry->name is a char [32].
>
> It maybe dangerous to TP_printk("%s", __entry->name)
> after the strncpy().
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This should go through the tree that has the code that uses these
tracepoints.
-- Steve
>
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
> include/trace/events/writeback.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
> index e7cbccc7c14c..57d795365987 100644
> --- a/include/trace/events/writeback.h
> +++ b/include/trace/events/writeback.h
> @@ -190,7 +190,7 @@ TRACE_EVENT(inode_foreign_history,
> ),
>
> TP_fast_assign(
> - strncpy(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32);
> + strscpy_pad(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32);
> __entry->ino = inode->i_ino;
> __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
> __entry->history = history;
> @@ -219,7 +219,7 @@ TRACE_EVENT(inode_switch_wbs,
> ),
>
> TP_fast_assign(
> - strncpy(__entry->name, bdi_dev_name(old_wb->bdi), 32);
> + strscpy_pad(__entry->name, bdi_dev_name(old_wb->bdi), 32);
> __entry->ino = inode->i_ino;
> __entry->old_cgroup_ino = __trace_wb_assign_cgroup(old_wb);
> __entry->new_cgroup_ino = __trace_wb_assign_cgroup(new_wb);
> @@ -252,7 +252,7 @@ TRACE_EVENT(track_foreign_dirty,
> struct address_space *mapping = page_mapping(page);
> struct inode *inode = mapping ? mapping->host : NULL;
>
> - strncpy(__entry->name, bdi_dev_name(wb->bdi), 32);
> + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
> __entry->bdi_id = wb->bdi->id;
> __entry->ino = inode ? inode->i_ino : 0;
> __entry->memcg_id = wb->memcg_css->id;
> @@ -285,7 +285,7 @@ TRACE_EVENT(flush_foreign,
> ),
>
> TP_fast_assign(
> - strncpy(__entry->name, bdi_dev_name(wb->bdi), 32);
> + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
> __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
> __entry->frn_bdi_id = frn_bdi_id;
> __entry->frn_memcg_id = frn_memcg_id;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] trace: fix potenial dangerous pointer
2020-11-24 17:05 ` [PATCH] trace: fix potenial dangerous pointer Steven Rostedt
@ 2020-11-24 17:09 ` Tejun Heo
2020-11-25 12:05 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2020-11-24 17:09 UTC (permalink / raw)
To: Steven Rostedt
Cc: Hui Su, mingo, jack, akpm, neilb, trond.myklebust, liuzhiqiang26,
tytso, cai, linux-kernel
On Tue, Nov 24, 2020 at 12:05:23PM -0500, Steven Rostedt wrote:
> On Wed, 25 Nov 2020 00:52:05 +0800
> Hui Su <sh_def@163.com> wrote:
>
> > The bdi_dev_name() returns a char [64], and
> > the __entry->name is a char [32].
> >
> > It maybe dangerous to TP_printk("%s", __entry->name)
> > after the strncpy().
>
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> This should go through the tree that has the code that uses these
> tracepoints.
Acked-by: Tejun Heo <tj@kernel.org>
Andrew, can you please route this one?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] trace: fix potenial dangerous pointer
2020-11-24 17:09 ` Tejun Heo
@ 2020-11-25 12:05 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2020-11-25 12:05 UTC (permalink / raw)
To: Tejun Heo
Cc: Steven Rostedt, Hui Su, mingo, jack, akpm, neilb,
trond.myklebust, liuzhiqiang26, tytso, cai, linux-kernel
On Tue 24-11-20 12:09:02, Tejun Heo wrote:
> On Tue, Nov 24, 2020 at 12:05:23PM -0500, Steven Rostedt wrote:
> > On Wed, 25 Nov 2020 00:52:05 +0800
> > Hui Su <sh_def@163.com> wrote:
> >
> > > The bdi_dev_name() returns a char [64], and
> > > the __entry->name is a char [32].
> > >
> > > It maybe dangerous to TP_printk("%s", __entry->name)
> > > after the strncpy().
> >
> > Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> >
> > This should go through the tree that has the code that uses these
> > tracepoints.
>
> Acked-by: Tejun Heo <tj@kernel.org>
>
> Andrew, can you please route this one?
I'll queue it to my tree and push it to Linus on Friday since I sometimes
handle writeback stuff myself anyway...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-25 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20201124165205.GA23937@rlk>
2020-11-24 17:05 ` [PATCH] trace: fix potenial dangerous pointer Steven Rostedt
2020-11-24 17:09 ` Tejun Heo
2020-11-25 12:05 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).