lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YEjGBec1pCxMvg6T@kernel.org>
Date:   Wed, 10 Mar 2021 10:13:41 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-kernel@...r.kernel.org, Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf synthetic events: Avoid write of uninitialized
 memory.

Em Wed, Mar 10, 2021 at 12:48:36PM +0100, Jiri Olsa escreveu:
> On Tue, Mar 09, 2021 at 03:49:45PM -0800, Ian Rogers wrote:
> > Account for alignment bytes in the zero-ing memset.
> > 
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> >  tools/perf/util/synthetic-events.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> > index b698046ec2db..31bf3dd6a1e0 100644
> > --- a/tools/perf/util/synthetic-events.c
> > +++ b/tools/perf/util/synthetic-events.c
> > @@ -424,7 +424,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
> >  
> >  	while (!io.eof) {
> >  		static const char anonstr[] = "//anon";
> > -		size_t size;
> > +		size_t size, aligned_size;
> >  
> >  		/* ensure null termination since stack will be reused. */
> >  		event->mmap2.filename[0] = '\0';
> > @@ -484,11 +484,12 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
> >  		}
> >  
> >  		size = strlen(event->mmap2.filename) + 1;
> > -		size = PERF_ALIGN(size, sizeof(u64));
> > +		aligned_size = PERF_ALIGN(size, sizeof(u64));
> >  		event->mmap2.len -= event->mmap.start;
> >  		event->mmap2.header.size = (sizeof(event->mmap2) -
> > -					(sizeof(event->mmap2.filename) - size));
> > -		memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
> > +					(sizeof(event->mmap2.filename) - aligned_size));
> > +		memset(event->mmap2.filename + size, 0, machine->id_hdr_size +
> > +			(aligned_size - size));
> 
> so we did not zero the extra alignment bytes, nice ;-) looks good
> 
> Acked-by: Jiri Olsa <jolsa@...hat.com>

That is really old:

Fixes: 1a853e36871b533c ("perf record: Allow specifying a pid to record")

Circa 2009, the PERF_RECORD_COMM is ok as TASK_COMM_LEN is 16.

But I think there are other places synthesizing PERF_RECORD_MMAP,
jitdump maybe:

tools/perf/bench/inject-buildid.c, but it uses memset to zero the whole
union, no problem.

tools/perf/util/jitdump.c
jit_repipe_code_load() but it uses calloc to allocate the union
perf_event, so no problem as well.

Thanks, applied.

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ