lkml.org 
[lkml]   [2019]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] tracing: Use strncpy instead of memcpy for string keys in hist triggers
From
Date
Hi Steve,

On Mon, 2019-03-04 at 16:22 -0600, Tom Zanussi wrote:
> Hi Steve,
>
> On Mon, 2019-03-04 at 16:56 -0500, Steven Rostedt wrote:
> > On Mon, 4 Mar 2019 16:50:00 -0500
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > > > +++ b/kernel/trace/trace_events_hist.c
> > > > @@ -4695,9 +4695,10 @@ static inline void add_to_key(char
> > > > *compound_key, void *key,
> > > > /* ensure NULL-termination */
> > > > if (size > key_field->size - 1)
> > > > size = key_field->size - 1;
> > > > - }
> > > >
> > > > - memcpy(compound_key + key_field->offset, key, size);
> > > > + strncpy(compound_key + key_field->offset, (char
> > > > *)key,
> > > > size);
> > > > + } else
> > > > + memcpy(compound_key + key_field->offset, key,
> > > > size);
> > > > }
> > > >
> > >
> > > Shouldn't we use strncpy() in save_comm() too. Feels safer.
> >
> > Note, if that is changed, it can be another patch. This one is fine
> > as
> > is. I just was looking at other use cases of memcpy() in that file.
> >
>
> Hmm, I don't think it's really necessary - it's not used in a key so
> don't care about anything after the null, and TASK_COMM_LEN is used
> in
> the memcpy.

Never mind, yeah, it would make sense to do this, will create another
patch...

Tom


>
> Tom
>
> > -- Steve

\
 
 \ /
  Last update: 2019-03-04 23:32    [W:0.446 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site